Application Development and Automation 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: 
Read only

move fields in bseg table

Former Member
0 Likes
928

Hi

Below is my bseg table data. My requirement is if line item 1 of zuonr is space i want to get this value from line 2 of kunnr.

BUKRS   BELNR        GJAHR    BUZEI    ZUONR      KUNNR
7063       0140951570  2009       001
7063   0140951570 2009  002   0000017017         0000055555

my output will be

BUKRS   BELNR        GJAHR    BUZEI    ZUONR      KUNNR
7063       0140951570  2009       001   0000055555      
7063   0140951570 2009  002   0000017017         0000055555

Hi

Below is my bseg table data. My requirement is if line item 1 of zuonr is space i want to get this value from line 2 of kunnr.

BUKRS   BELNR        GJAHR    BUZEI    ZUONR      KUNNR
7063       0140951570  2009       001
7063   0140951570 2009  002   0000017017         0000055555

my output will be

BUKRS   BELNR        GJAHR    BUZEI    ZUONR      KUNNR
7063       0140951570  2009       001   0000055555      
7063   0140951570 2009  002   0000017017         0000055555

6 REPLIES 6
Read only

Former Member
0 Likes
868

Hi Kumar,

Define one more table (itab2) of same structure.

Loop at 1st table.

Itab2-bukrs = itab1-bukrs.

Itab2-belnr = itab1-belnr.

Itab2-gjahr = itab1-gjahr.

Itab2-bezei = itab1-bezei.

If itab1-zuonr = space.

Itab2-zuonr = itab1-kunnr.

Else.

Itab2-zuonr = itab1-zuonr.

Endif.

Append itab2.

Endloop.

Hope this will help you.

Best Regards,

Deepa Kulkarni

Read only

Sandeep_Panghal
Product and Topic Expert
Product and Topic Expert
0 Likes
868

Loop at itab.

read table itab into wa with key bukrs belnr gjahr Kunnr ne space.

if sy-subrc eq 0.

itab-zuonr = wa-kunnr.

modify itab .

endif.

endloop.

Read only

Former Member
0 Likes
868

be clear if u hve only 2 entries of lineitems with same unique keys.

loop at ur internaltable. now if the zounr val is space then increment the sy-tabix value.

and read that particular line item and get the value of kunnr. Now assign this to the zounr in the loop.

Read only

Former Member
0 Likes
868

hi

make two work area wa1 and wa2 like itab.

now use the following code

loop at itab into wa1.

if wa1-zuonr = space.

flage = 'X'.

elseif flage = 'X'.

data ind TYPE i.

ind = sy-tabix - 1.

read table itab into wa2 index ind.

wa2-zuonr = wa1-kunnr.

modify itab from wa2 index ind.

CLEAR wa2.

CLEAR flage.

endif.

ENDLOOP.

Read only

Former Member
0 Likes
868

if u dont mind can know y you want to do so?????

Read only

Former Member
0 Likes
868

or you can use the following code

loop at itab into wa1.

if wa1-zuonr = space.

data ind type i.

ind = sy-tabix + 1.

read table itab into wa2 index ind.

wa1-zuonr = wa2-kunnr.

modify itab from wa1.

CLEAR wa2.

endif.

ENDLOOP.