Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

logic to get same text for 2 line items

Former Member
0 Kudos

hi all,

i have an issue in my report,

i have a final internal table. fileds in the table are

bukrs belnr gjahr buzei sgtxt

0010 12345 2008 01 text

0010 12345 2008 02 -


now the problem is if the belnr is same thn in the final internal table the above sgtxt shoud come for second line item if the second line item is initial ,i shoud get the output as

bukrs belnr gjahr buzei sgtxt

0010 12345 2008 01 text

0010 12345 2008 02 text

please help me how to write code for this

3 REPLIES 3

Sandeep_Kumar
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi,

Use this :

Loop at itab.

if itab-sgtext is initial .

read table itab into wa with key bukrs = itab-bukrs

belnr = itab-bukrs

gjahr = itab-bukrs

buzei = itab-bukrs

sgtext <> space.

if sy-subrc eq 0.

itab-sgtext = wa-sgtext.

modify itab transporting sgtext.

endif.

endif.

endloop.

Hope this helps.

Rgds,

Sandeep

Former Member
0 Kudos

Hi,

u can do as follows...


DATA: ITAB_T LIKE LINE OF <ITAB>,
          SGTXT_T TYPE <ITAB>-SGTXT.

SORT <ITAB> BY BELNR SGTXT

LOOP AT <ITAB>.
   ITAB_T = <ITAB>.
   AT NEW BELNR.
      T_BELNR = <ITAB_T-SGTXT.
   ENDAT.
   IF <ITAB>-SGTXTR IS INITIAL.
      ITAB_T-SGTXT = SGTXT_T.
   ENDIF.
   APPEND ITAB_T INTO <ITAB_FINAL>.
   CLEAR: ITAB_T,
               SGTXT_T.
ENDLOOP.

Former Member
0 Kudos

Hi,

Move this values to one more internal table.

Loop at 1 internal table.

read second internal table with belnr.

If check that text is initial.

second internal text = first internal table text.

endif.

Modify second internal table with text.

endloop..

Now 2 internal table will have all the rows with text