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

table for MATNR & VBELN

Former Member
0 Likes
5,063

Hi experts,

for which table I'll get output as MATNR if i have input as VBELN?

Do I need anyother fields to identify MATNR or only VBELN is sufficent?

Points will be rewarded.

Thanks in advance.

neo S.

2 REPLIES 2
Read only

Former Member
0 Likes
3,005

Hi,

Please try this tables with line item (POSNR).

VBAP for sales order

VBRP for billing

LIPS for delivery

Regards,

Ferry Lianto

Read only

aris_hidalgo
Contributor
0 Likes
3,005

Hi,

What you can do is to to link VBAK-VBELN to VBAP-VBELN and get the MATNR from VBAP table.Here is an example:


REPORT  z_aris_test_13.

TABLES: vbak.

DATA: gt_vbak TYPE STANDARD TABLE OF vbak,
      gt_vbap TYPE STANDARD TABLE OF vbap,
      wa_vbak LIKE LINE OF gt_vbak,
      wa_vbap LIKE LINE OF gt_vbap.

START-OF-SELECTION.

  SELECT *
  FROM vbak
  INTO TABLE gt_vbak.

  IF NOT gt_vbak[] IS INITIAL.
    SELECT *
    FROM vbap
    INTO TABLE gt_vbap
    FOR ALL ENTRIES IN gt_vbak
    WHERE vbeln = gt_vbak-vbeln.

    SORT gt_vbak BY vbeln ASCENDING.
    SORT gt_vbap BY vbeln ASCENDING.
  ENDIF.

END-OF-SELECTION.
  IF NOT gt_vbak[] IS INITIAL.
    LOOP AT gt_vbak INTO wa_vbak.
      READ TABLE gt_vbap INTO wa_vbap WITH KEY vbeln = wa_vbak-vbeln
                                                       BINARY SEARCH.
      IF sy-subrc = 0.
        WRITE: / wa_vbap-matnr.
      ENDIF.
    ENDLOOP.
  ENDIF.