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

Re: Internal Table Output using Field symbols

$
0
0

Hi Kaur,

 

I would suggest you have a third internal table with the same structure as first internal table.

 

If I have understood correctly, you want to determine the field name (fld2) that is used for validation dynamically.

 

Try this logic.

 

DATA : it_itab1 TYPETABLEOF ty_itab1,
         it_itab2 TYPETABLEOF ty_itab1,
         it_itab3 TYPETABLEOF ty_itab2,
         wa_itab1 TYPE ty_itab1,
         wa_itab2 type ty_itab1,
         wa_itab3 TYPE ty_itab2,
         lv_prev_fld1 type string,

          field_name type string.

 

FIELD-SYMBOLS : <fs1>,<fs2>.

 

" As required the field name can be assigned dynamically, maybe from a parameter.

field_name = 'FLD2'.  

assign wa_itab1 to<fs1>.

loopat it_itab3 into wa_itab3.
   loopat it_itab1 into wa_itab1.
     assigncomponent field_name ofSTRUCTURE<fs1> to<fs2>.
     if<fs2> isASSIGNEDand<fs2> = 'AA'.  " AA can also be provided dynamically if required
       concatenate wa_itab1-fld1+0(1) wa_itab3-fld3 into wa_itab1-fld1.
       wa_itab1-fld3 = wa_itab3-fld3.
       append wa_itab1 to it_itab2.
     elseifnot lv_prev_fld1 isINITIAL.
       wa_itab1-fld1 = lv_prev_fld1.
       append wa_itab1 to it_itab2.
     endif .
     lv_prev_fld1 = wa_itab1-fld1.
    endloop.
endloop.

 

The output is as required.



Assuming, fld1 and fld3 are character/string fields. Else you have to move them to string field to perform the concatenate operation.


Viewing all articles
Browse latest Browse all 10473

Trending Articles



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