Application Development 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: 

Issue with table s031 and with for all entries.

Former Member
0 Kudos

Hi,

I have following code in which select statement on s031 is
taking long time and after that it shows a dump. What should I do instead of
exceeding the time limit of execution of an abap program.

TYPES:

 
BEGIN OF TY_MTL" Material Master

    MATNR
TYPE MATNR,   " Material Code

    MTART
TYPE MTART,   " Material Type

    MATKL
TYPE MATKL,   " Material Group

    MEINS
TYPE MEINS,   " Base unit of Measure

    WERKS
TYPE WERKS_D, " Plant

    MAKTX
TYPE MAKTX,   " Material description (Short Text)

    LIFNR
TYPE LIFNR,   " vendor code

    NAME1
TYPE NAME1_GP, " vendor name

    CITY 
TYPE ORT01_GP, " City of Vendor

    Y_RPT
TYPE P DECIMALS 3, "Yearly receipt

    Y_ISS
TYPE P DECIMALS 3, "Yearly Consumption

    M_OPG
TYPE P DECIMALS 3, "Month opg

    M_OPG1
TYPE P DECIMALS 3,

    M_RPT
TYPE P DECIMALS 3, "Month receipt

    M_ISS
TYPE P DECIMALS 3, "Month issue

    M_CLG
TYPE P DECIMALS 3, "Month Closing

    D_BLK
TYPE P DECIMALS 3, "Block Stock,

    D_RPT
TYPE P DECIMALS 3, "Today receipt

    D_ISS
TYPE P DECIMALS 3, "Day issues

    TL_FL
(2) TYPE C,

    STATUS
(4) TYPE C,

END OF TY_MTL,
BEGIN OF TY_OPG     , " Opening File

       SPMON
TYPE SPMON,   " Period to analyze - month

       WERKS
TYPE WERKS_D, " Plant

       MATNR
TYPE MATNR,   " Material No

       BASME
TYPE MEINS,

       MZUBB
TYPE MZUBB,   " Receipt Quantity

       WZUBB
TYPE WZUBB,

       MAGBB
TYPE MAGBB,   " Issues Quantity

       WAGBB
TYPE WAGBB,
END OF TY_OPG,

DATA :

       T_M 
TYPE STANDARD TABLE OF TY_MTL INITIAL SIZE 0,

       WA_M
TYPE TY_MTL,

       T_O 
TYPE STANDARD TABLE OF TY_OPG INITIAL SIZE 0,

       WA_O
TYPE TY_OPG.

DATA: smonth1      TYPE spmon.  

SELECT

  a
~matnr

  a
~mtart

  a
~matkl

  a
~meins

  b
~werks

 
INTO TABLE t_m FROM mara AS a

  INNER
JOIN marc AS b

 
ON a~matnr = b~matnr
*  WHERE a~mtart EQ s_mtart

 
WHERE a~matkl IN s_matkl

 
AND b~werks IN s_werks

 
AND b~matnr IN s_matnr   .

 
endif.

SELECT spmon

       werks

       matnr

       basme

       mzubb

       WZUBB

       magbb

       wagbb

       
FROM s031 INTO TABLE t_o

       
FOR ALL ENTRIES IN t_m

       
WHERE matnr = t_m-matnr

       
AND werks IN s_werks

         
AND spmon le smonth1

         
AND basme = t_m-meins.

6 REPLIES 6

Abhijit74
Active Contributor
0 Kudos

This message was moderated.

Former Member
0 Kudos

Hi Hitesh,

You are getting the data to the internal table t_o by comparing with the entries in the t_m.

before doing this please follow this steps.

1.sort the for all entries internal table with the primary key.

2.delete the adjacent duplicates from the internal table.

3. then you select the data to the second internal table.

Thanks.

Pavan.

Former Member
0 Kudos

Hi Hitesh,

please select in different way.

take one Internal table for MARA.I_MARA

Take another Internal Table for MARC.i_MARC

Take one final table which contains both tables Field. I_FINAL

Now select from MARA and keep into I_MARA

Now FOR ALL ENTRIES IN I_MARA .  Select from MARC and keep into I_MARC.

Now joined both table and keep into Table I_FINAL.(Use LOOP AND READ )

Thanks

Tarak

former_member946717
Contributor
0 Kudos

This message was moderated.

Former Member
0 Kudos

hi,

when innter table t_m have a large amount of  data and use syntax  for all entries,the program will dump.

I think you should  use t_code sat to find why  the program run long time.and use another way to write.

Former Member
0 Kudos

Hi Hitesh,

It seems that you have a very large amount of data in the internal table and that is why it is giving dump.One way out is to optimize your query and use packet size like in the following sample query ,as:

IF p_gt_zsas_mcg_mapping IS NOT INITIAL.

* Material based on Plamt/storage location from MARD

    SELECT a~matnr

           b~werks

           b~lgort

           a~meins

          INTO CORRESPONDING FIELDS OF  TABLE p_gt_materials

      PACKAGE SIZE p_gv_psize

      FROM ( mara AS a INNER JOIN  mard AS b ON a~matnr = b~matnr )

      FOR ALL ENTRIES IN p_gt_zsas_mcg_mapping

      WHERE b~werks = p_gt_zsas_mcg_mapping-werks

      AND  b~lgort = p_gt_zsas_mcg_mapping-lgort.

This will reduce the amount of data in the internal table and then can be used in the FOR ALL ENTRIES option.Please do not forget to sort the internal table before calling the FOR ALL ENTRIES.

Hope it helps,

Thanks,

Nitin