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

Retrieving data for a single field from joining table

Former Member
0 Likes
1,866

Dear All,

I am new to ABAP. I am working on SQ02 for creating queries. My question is:

I have created an infoset by directing reading table VBAK - Sales Order Header Data. Now I have added an additional field called Material no. I want to join VBAK with VBAP - Sales Order Item data thru query. I have tried on this, but it is fetching only one record while for the selected Sales order there are multiple item data.

Please help me how to do this thru query.

Regards

Rajesh

Dear All,

I am new to ABAP. I am working on SQ02 for creating queries. My question is:

I have created an infoset by directing reading table VBAK - Sales Order Header Data. Now I have added an additional field called Material no. I want to join VBAK with VBAP - Sales Order Item data thru query. I have tried on this, but it is fetching only one record while for the selected Sales order there are multiple item data.

Please help me how to do this thru query.

Regards

Rajesh

7 REPLIES 7
Read only

ramkumar007
Participant
0 Likes
1,663

pls post your program

Read only

0 Likes
1,663

Hi Ramkumar,

I have not written any program. I am doing this thru SQ02. Where i have inserted table VBAK at the initial stage. Now I want Material numbers from VBAP table. I have added an additional field called material.

When I run query it is showing only one record which is the last material in that SO. There are two line items in the same order.

I have written code as per below:

RECORD PROCESSING

select matnr into mn from vbap  where vbeln = vbak-vbeln.

endselect.

then in the field

fieldname = mn.

Regards,

Rajesh

Read only

ramkumar007
Participant
0 Likes
1,663

hi,

 

  you know that internal table and workarea declaration .

Regards

ram

Read only

0 Likes
1,663

Hi Ramkumar,

Thanks for your prompt reply. Sorry, I dont know about that. I appreciate if you can help me for programming  for me a sample for my query.

Regards,

Rajesh

Read only

0 Likes
1,663

Please use table join option to join VBAK and VBAP instead of writing code.

Regards

Read only

ramkumar007
Participant
0 Likes
1,663

   REPORT  ZRAM_RETRIEVING_VBAK_VBAP NO STANDARD PAGE HEADING.

TYPES : BEGIN OF ty_vbak,
        vbeln TYPE vbeln_va,
        END OF ty_vbak,
        BEGIN OF ty_vbap,
        vbeln TYPE vbeln_va,
        matnr TYPE matnr,
        END OF ty_vbap.

data : it_vbak TYPE TABLE OF ty_vbak,
       it_vbap TYPE TABLE OF ty_vbap,
       wa_vbak type ty_vbak,
       wa_vbap TYPE ty_vbap.

PARAMETERS :vbeln1 TYPE  VBAP-VBELN.

select vbeln from vbak
    into TABLE it_vbak WHERE vbeln = vbeln1.


   SELECT vbeln

                matnr

                    FROM vbap
                             INTO TABLE it_vbap FOR ALL ENTRIES IN it_vbak
                                          WHERE vbeln = it_vbak-vbeln .
LOOP AT it_vbap INTO wa_vbap.
WRITE :/ wa_vbap-matnr .
ENDLOOP.

Read only

0 Likes
1,661

Hi Ramkumar,

Thanks for coding. It has helped me for my output. But still i have not achieved my desire output. after adding the coding when I run query, output is as per below. this fields i have selected as output from SQ01.

After this output when i press back i get below output.

If i want to combine both in one what should I do.

Please help me on this.

Regards,

Rajesh