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

ABAP performance problem

0 Likes
646

Hello Guys:

                We have a requirement to check if purchase order no exist when users create sales order.

                 Because SAP standard funcation can only check this for certain customer.

                 So we develop a userexit to check if purchase order no exist for all customers, but the performance is badwhen creating sales order.

                 If we can improve the ABAP program by SQL, or other solutions?

                Please give me sone advices,thanks.

              

TYPES: BEGIN OF tt_zzz,

          vbeln like vbkd-vbeln,

          bstkd like vbkd-bstkd,

          vkorg like vbak-vkorg,

        END OF tt_zzz.

DATA: wa_zzz TYPE tt_zzz.

if vbak-auart = '***'.

   move vbkd to tmp_vbkd.

   SELECT SINGLE

     vbkd~vbeln

     vbkd~BSTKD

     vbak~vkorg

   INTO CORRESPONDING FIELDS OF wa_zzz

   FROM vbkd

   INNER JOIN vbak

   ON vbak~vbeln = vbkd~vbeln

   WHERE vbkd~bstkd = tmp_vbkd-bstkd

   AND vbkd~vbeln <> tmp_vbkd-vbeln

   AND vbak~vkorg LIKE '***%'

   AND vbak~auart = '***'.

   if sy-subrc = 0. "PO Exist

     if sy-tcode = 'VA01'.

       MESSAGE e115(v4).

     ELSE.

       MESSAGE w115(v4).

     ENDIF.

   ENDIF.

Stephen

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
536

Hi Stephen,

SELECT

     vbkd~vbeln

     vbkd~BSTKD

     vbak~vkorg

   INTO TABLE it_zzz

   FROM vbkd

   INNER JOIN vbak

   ON vbak~vbeln = vbkd~vbeln

   WHERE vbkd~bstkd = tmp_vbkd-bstkd

   .

loop at it_zzz into wa_zzz where vbeln <> tmp_vbkd-vbeln.

      if wa_zzz-vkorg+0(2) = '**' and wa_zzz-auart = '***'.

         if sy-tcode = 'VA01'.

           MESSAGE e115(v4).

         ELSE.

           MESSAGE w115(v4).

         ENDIF.

      endif.

endloop.

regards,

Archer

3 REPLIES 3
Read only

Former Member
0 Likes
536

Hello Stephen,

You may create an index on VBKD-BSTKD.

But keep in mind that two many indexes could slow down performances.

Regards

Read only

Former Member
0 Likes
537

Hi Stephen,

SELECT

     vbkd~vbeln

     vbkd~BSTKD

     vbak~vkorg

   INTO TABLE it_zzz

   FROM vbkd

   INNER JOIN vbak

   ON vbak~vbeln = vbkd~vbeln

   WHERE vbkd~bstkd = tmp_vbkd-bstkd

   .

loop at it_zzz into wa_zzz where vbeln <> tmp_vbkd-vbeln.

      if wa_zzz-vkorg+0(2) = '**' and wa_zzz-auart = '***'.

         if sy-tcode = 'VA01'.

           MESSAGE e115(v4).

         ELSE.

           MESSAGE w115(v4).

         ENDIF.

      endif.

endloop.

regards,

Archer

Read only

Former Member
0 Likes
536

Hi Stephen.

Please check, if you can SELECT for BSTKD_M instead of BSTKD. There should be secondary index VBKD-BST for that. You need to compare the value in UPPERCASE mode then.

Also I don't understand your scan for VKORG LIKE '***%' and AUART EQ '***'.

"%" represents any character string, even an empty one, and "_" represents any

character after LIKE. What do you want to check here? To check for a 3 character AUART you need to compare with

AUART LIKE '___'. If you want to search an '%' then you need an escape character, too.

Regards,

Klaus