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: 

adding the fields

Former Member
0 Kudos

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.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

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.

5 REPLIES 5

Former Member
0 Kudos

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 Kudos

In the secondary list all the values adding by 1 , but i want the addition of kunnr and vbeln.

can u help me...

Regards.Thiru.

Former Member
0 Kudos

Hi,

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 vbeln.

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.

sy-tabix = 2 + sy-tabix.

READ LINE sy-tabix FIELD VALUE v_kun

INTO wa.

total = wa1-vbeln + wa-kunnr.

WRITE : / wa1-vbeln , total, wa.

CLEAR : wa1-vbeln , total.

ENDLOOP.

Try this Code.

Thanks,

Durai.V

0 Kudos

Hello Durai,

in first list i want kunnr and (kunnr+100) , when i double click on kunnr in first list

it must display the vbeln and (vbeln+kunnr) in secondary list...

Former Member
0 Kudos

hi,

dont close the forum untill it get resolved.

this solution is executing properly. check it .

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.

IF sy-subrc NE 0.

wa1-vbeln = '1982'.

APPEND wa1 TO it1.

CLEAR wa1.

wa1-vbeln = '1983'.

APPEND wa1 TO it1.

CLEAR wa1.

wa1-vbeln = '1984'.

APPEND wa1 TO it1.

CLEAR wa1.

wa1-vbeln = '1985'.

APPEND wa1 TO it1.

CLEAR wa1.

ENDIF.

ENDIF.

LOOP AT it1 INTO wa1.

index = sy-tabix.

LOOP AT it INTO wa FROM index TO index.

total = wa1-vbeln + wa-kunnr.

WRITE : / wa1-vbeln , total.

CLEAR index.

EXIT.

ENDLOOP.

CLEAR : wa1-vbeln , total.

ENDLOOP.