Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 2067

Re: How can i use the CASE inside a Loop ?

$
0
0

You can move the string into a structure, which has the two data elements as fields:

 

TYPES: BEGIN OF ty_kg_kb,

               prefix TYPE char LENGTH 2,

               data TYPE char LENGTH 3,

             END OF ty_kg_kb.

 

DATA ls_kg_kb TYPE ty_kg_kb.

 

...

 

ls_kg_kb = <gs_table_string>.

 

CASE ls_kg_kb-prefix.

     WHEN 'KG'.

          ...

     WHEN 'KB'. " maybe use constant?

          ...



Why do you need two tables? You can also put the data into one table of the above specified line type and work with a GROUP BY in the LOOP (precondition NW 7.4 SP08).


LOOP AT lt_kg_kb ASSIGNING FIELD-SYMBOL(<ls_kg_kb>)

     GROUP BY ( prefix ) INTO DATA(ls_prefix).


     WRITE: / ls_prefix-prefix.


     LOOP AT GROUP ls_prefix ASSIGNING FIELD-SYMBOL(<ls_member>).

          WRITE: / <ls_member>-data.

     ENDLOOP.


ENDLOOP.


Viewing all articles
Browse latest Browse all 2067

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>