Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

adding the fields

Hi in the below code i want to add the values of vbeln and kunnr in secondary list but it is not coming fine can anyone solve my problem....

data : begin of wa,

kunnr type kunnr,

end of wa.

data it like table of wa.

data : begin of wa1,

vbeln type vbeln,

end of wa1,

it1 like table of wa1.

data : v_kun type i.

data : field type string,

value type kunnr.

data : total type i.

select kunnr into table it from kna1 up to 4 rows.

loop at it into wa.

v_kun = wa-kunnr + 100.

write : / wa-kunnr, v_kun.

endloop.

at line-selection.

get cursor field field value value.

if field = 'WA-KUNNR'.

select vbeln from vbak into table it1 up to 4 rows.

endif.

loop at it1 into wa1.

total = wa1-vbeln + wa-kunnr.

write : / wa1-vbeln , total.

clear : wa1-vbeln , total.

endloop.

Regards,

Thiru.

Tags:
Former Member
Former Member replied

you need to read the table it in secondary list than only u will get value in wa. in ur case wa-kunnr in intial in secondary list.

here u dont have any coomon key between the two table so use loop in side loop and add.

see the added code.

data : begin of wa,

kunnr type kunnr,

end of wa.

data it like table of wa.

data : begin of wa1,

vbeln type vbeln,

end of wa1,

it1 like table of wa1.

data : v_kun type i.

data : field type string,

value type kunnr.

data : total type i,

index type i.

select kunnr into table it from kna1 up to 4 rows.

loop at it into wa.

v_kun = wa-kunnr + 100.

write : / wa-kunnr, v_kun.

endloop.

at line-selection.

get cursor field field value value.

if field = 'WA-KUNNR'.

select vbeln from vbak into table it1 up to 4 rows.

endif.

loop at it1 into wa1.

loop at it into wa where index eq sy-index.

total = wa1-vbeln + wa-kunnr.

write : / wa1-vbeln , total.

clear index.

exit.

endloop.

clear : wa1-vbeln , total.

endloop.

Regards,

Thiru.

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question