Tuesday 31 May 2016

For all entries


  • Syntax
... FOR ALL ENTRIES IN itab WHERE ... col operator itab-comp ...

  • If the addition FOR ALL ENTRIES is specified before the language element WHERE of the SELECT statement, the components comp of the internal table itab specified there can be used in sql_cond as the operands of comparisons with relational operators.
  • The specified component comp must be compatible with the column col.
  • The internal table itab can have a structured or an elementary row type. For an elementary row type, the pseudo component table_line must be specified for comp.

Note


  1. Check the for all entries table  is not empty  or not.
  2. Write all key field in selection criteria.
  3. Data type and length of for all entries matching field should be match for both the table.
Ex :

Steps

  1. Go to transaction code SE38.
  2. Enter the program name Z or Y<program name>
  3. Select attribute type as Executable program.
  4. Click on Save.

Source Code




REPORT  ZFORALLENTRIES.

TYPESBEGIN OF TY_SA,
       VBELN TYPE VBAK-VBELN,
       ERDAT TYPE VBAK-ERDAT,
       ERNAM TYPE VBAK-ERNAM,
       NETWR TYPE VBAK-NETWR,
       VKORG TYPE VBAK-VKORG,
       POSNR TYPE VBAP-POSNR,
       MATNR TYPE VBAP-MATNR,
       END OF TY_SA.


TYPES BEGIN OF TY_MAT,
        MATNR TYPE MAKT-MATNR,
        MAKTX TYPE MAKT-MAKTX,
        END OF TY_MAT.

TYPES BEGIN OF TY_SO,
       VBELN TYPE VBAK-VBELN,
       ERDAT TYPE VBAK-ERDAT,
       ERNAM TYPE VBAK-ERNAM,
       NETWR TYPE VBAK-NETWR,
       VKORG TYPE VBAK-VKORG,
       POSNR TYPE VBAP-POSNR,
       MATNR TYPE VBAP-MATNR,
       MAKTX TYPE MAKT-MAKTX,
      END OF TY_SO.

 DATA WA_SA TYPE TY_SA,
        IT_SA TYPE SORTED TABLE OF TY_SA WITH  NON-UNIQUE KEY ERNAM,
        WA_MAT TYPE TY_MAT,
        IT_MAT TYPE TABLE OF TY_MAT,
        WA_SO TYPE TY_SO,
        IT_SO TYPE TABLE OF TY_SO.


SELECT-OPTIONS S_VBELN FOR WA_SA-VBELN.


SELECT A~VBELN
       A~ERDAT
       A~ERNAM
       A~NETWR
       VKORG
       POSNR
       MATNR  INTO TABLE IT_SA FROM VBAK AS A INNER JOIN VBAP AS B
       ON B~VBELN A~VBELN WHERE A~VBELN IN S_VBELN  .


  IF IT_SA  IS NOT INITIAL.

    SELECT MATNR MAKTX FROM MAKT INTO TABLE IT_MAT FOR ALL ENTRIES IN IT_SA

      WHERE MATNR IT_SA-MATNR AND  SPRAS 'EN'.


  ENDIF.



LOOP AT IT_SA INTO WA_SA.
  WA_SO-VBELN WA_SA-VBELN.
  WA_SO-ERDAT  WA_SA-ERDAT.
  WA_SO-ERNAM    WA_SA-ERNAM.
  WA_SO-NETWR  WA_SA-NETWR.
  WA_SO-VKORG WA_SA-VKORG.
  WA_SO-POSNR  WA_SA-POSNR.
  WA_SO-MATNR  WA_SA-MATNR.

 CLEAR WA_MAT.
  READ TABLE   IT_MAT  INTO WA_MAT WITH  KEY MATNR WA_SA-MATNR BINARY SEARCH.
 IF SY-SUBRC 0.
  WA_SO-MAKTX WA_MAT-MAKTX.

 ENDIF.


  APPEND WA_SO TO IT_SO.


ENDLOOP.



LOOP AT IT_SO INTO WA_SO.

  WRITE / WA_SO-VBELN ,
            WA_SO-ERDAT,
            WA_SO-ERNAM,
            WA_SO-NETWR,
            WA_SO-VKORG,
            WA_SO-POSNR,
            WA_SO-MATNR,
            WA_SO-MAKTX.

ENDLOOP.

Input


Output


No comments:

Post a Comment