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

report

Former Member
0 Likes
406

hi experts

plse tell me is there any thing wrong in the below logic,i am not getting values to the wa_stko.

SELECT matnr

werks

stlnr

FROM mast

INTO TABLE i_mast

FOR ALL ENTRIES IN i_marc

WHERE matnr = i_marc-matnr AND

stlan = '1' AND

stlal = '01'.

ENDIF .

IF NOT i_mast IS INITIAL.

SELECT stlnr

FROM stko

INTO TABLE i_stko

FOR ALL ENTRIES IN i_mast

WHERE stlnr = i_mast-stlnr AND

datuv IN r_datuv AND "sy-datum to be changed

loekz NE 'X' AND

stlst = '1'.

ENDIF .

LOOP AT i_stko INTO wa_stko .

  • LOOP AT i_mast INTO wa_mast WHERE stlnr = wa_stko-stlnr.

READ TABLE i_mast INTO wa_mast WITH KEY stlnr = wa_stko-stlnr.

wa_stko-matnr = wa_mast-matnr.

wa_stko-werks = wa_mast-werks.

wa_stko-stlnr = wa_mast-stlnr.

with regads

sermarao

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
386

i have declared the internal table correctly

with regards

sermarao

3 REPLIES 3
Read only

Former Member
0 Likes
387

i have declared the internal table correctly

with regards

sermarao

Read only

0 Likes
386

Hi,

Try the below code. This seems to be working fine.

TYPES : BEGIN OF t_mast ,

matnr TYPE mast-matnr,

werks TYPE mast-werks,

stlnr TYPE mast-stlnr,

END OF t_mast,

BEGIN OF t_stko ,

stlnr TYPE mast-stlnr,

matnr TYPE mast-matnr,

werks TYPE mast-werks,

END OF t_stko.

DATA: i_mast TYPE STANDARD TABLE OF t_mast,

i_stko TYPE STANDARD TABLE OF t_stko,

i_marc TYPE STANDARD TABLE OF marc,

wa_mast TYPE t_mast,

wa_stko TYPE t_stko.

RANGES: r_datuv FOR sy-datum.

SELECT * FROM marc

INTO TABLE i_marc.

SELECT matnr

werks

stlnr

FROM mast

INTO TABLE i_mast

FOR ALL ENTRIES IN i_marc

WHERE matnr = i_marc-matnr AND

stlan = '1' AND

stlal = '01'.

IF NOT i_mast IS INITIAL.

SELECT stlnr

FROM stko

INTO TABLE i_stko

FOR ALL ENTRIES IN i_mast

WHERE stlnr = i_mast-stlnr AND

datuv IN r_datuv AND

loekz NE 'X' AND

stlst = '1'.

IF sy-subrc IS INITIAL.

LOOP AT i_stko INTO wa_stko .

READ TABLE i_mast INTO wa_mast WITH KEY stlnr = wa_stko-stlnr.

IF sy-subrc IS INITIAL.

wa_stko-matnr = wa_mast-matnr.

wa_stko-werks = wa_mast-werks.

wa_stko-stlnr = wa_mast-stlnr.

ENDIF.

ENDLOOP.

ENDIF.

ENDIF .

Reward points if helpful.

Read only

Former Member
0 Likes
386

Hi Sema,

Your requirment is not totally clear.Means according to the code you menytioned you will not get all the values in the wa_stko.Do you want to append all the values of wa_stko to a table?

If so then try the code below-

-


LOOP AT i_stko INTO wa_stko .

LOOP AT i_mast INTO wa_mast WHERE stlnr = wa_stko- stlnr.

wa_stko-matnr = wa_mast-matnr.

wa_stko-werks = wa_mast-werks.

wa_stko-stlnr = wa_mast-stlnr.

APPEND wa_stko TO table.

CLEAR: wa_mast,wa_stko.

ENDLOOP.

ENDLOOP.