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

Internal table oerations using for all entries

Former Member
0 Likes
962

Hi folks

I want to display an output of

SO number, SO Date( from VBAK) ,

SO Item, SO item category (from VBAP) ,

MAterial no., MAt type (from MARA)

Using 3 internal tables for each table fields and applying FOR ALL ENTRIES and populating a final output table say I_output.

Can u please give me a SAMPLE CODE on this.

I wont forget to reward points

Regards,RAM

Hi folks

I want to display an output of

SO number, SO Date( from VBAK) ,

SO Item, SO item category (from VBAP) ,

MAterial no., MAt type (from MARA)

Using 3 internal tables for each table fields and applying FOR ALL ENTRIES and populating a final output table say I_output.

Can u please give me a SAMPLE CODE on this.

I wont forget to reward points

Regards,RAM

4 REPLIES 4
Read only

Former Member
0 Likes
698

select vbakdate vbakvbeln vbapitem vbapitemcat vbapmatnr into corresponding fields of table i_vbap from vbak inner join vbap on vbakvbeln = vbap~vbeln where ..........<you where condn as per selection screen>.

select mtart from mara into table i_mara from mara for all entries in i_vbap where matnr = i_vbap-matnr.

loop at i_vbap.

move-corresponding i_vbap to i_final.

read table i_mara with key matnr = i_vbap-matnr.

i_final-mtart = i_mara-mtart.

append i_final.

endloop.

regards

shiba dutta

Read only

former_member582701
Contributor
0 Likes
698

You need something like this i think:

SELECT KNA1KUNNR KNA1ERDAT KNA1STCD1 KNB1BUKRS

INTO TABLE i_kna1

FROM KNB1 INNER JOIN KNA1

ON KNB1mandt = KNA1MANDT AND

KNB1KUNNR = KNA1KUNNR

FOR ALL ENTRIES IN i_land1

WHERE KNA1~MANDT = SY-MANDT AND

KNA1~KUNNR IN s_zkunnr AND

KNA1~KONZS IN s_konzs AND

KNA1~BRSCH IN s_brsch AND

KNA1~PFACH IN s_pfach AND

KNA1~LOEVM NE space AND

KNA1~UPDAT > p_updat AND

KNA1~LAND1 = i_land1-land1.

You need change KNA1 for VBAK, KNB1 for VBAP (with your corresponding fields) and i_land1 for iternal table with all materials. In i_kna1 you will have your output.

Regards

Read only

Former Member
0 Likes
698

hi

pls see the following code...


DATA: BEGIN OF it_vbak OCCURS 0,
      vbeln TYPE vbeln,
      erdat TYPE sy-datum,
      END OF it_vbak,

      BEGIN OF it_vbap OCCURS 0,
      vbeln TYPE vbeln,
      posnr TYPE posnr,
      matnr TYPE matnr,
      pstyv TYPE pstyv,
      END OF it_vbap,

      BEGIN OF it_mara OCCURS 0,
      matnr TYPE matnr,
      mtart TYPE mtart,
      END OF it_mara,

      BEGIN OF it_final OCCURS 0,
      vbeln TYPE vbeln,
      erdat TYPE sy-datum,
      posnr TYPE posnr,
      matnr TYPE matnr,
      pstyv TYPE pstyv,
      mtart TYPE mtart,
      END OF it_final.



SELECT vbeln erdat INTO TABLE it_vbak FROM vbak.

IF NOT it_vbak[] IS INITIAL.
  SELECT vbeln posnr matnr pstyv INTO TABLE it_vbap FROM vbap
  FOR ALL ENTRIES IN it_vbak WHERE vbeln = it_vbak-vbeln.

  IF NOT it_vbap[] IS INITIAL.
    SELECT matnr mtart INTO TABLE it_mara FROM mara
    FOR ALL ENTRIES IN it_vbap WHERE matnr = it_vbap-matnr.
  ENDIF.

ENDIF.

LOOP AT it_vbak.
  MOVE-CORRESPONDING it_vbak TO it_final.
  LOOP AT it_vbap WHERE vbeln = it_vbak-vbeln.
    READ TABLE it_mara WITH KEY matnr = it_vbap-matnr.
    MOVE-CORRESPONDING it_vbap TO it_final.
    MOVE-CORRESPONDING it_mara TO it_final.
    APPEND it_final.
  ENDLOOP.
ENDLOOP.

thx

pavan

**pls reward for helpful answers

Read only

Former Member