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

badi logic help

Former Member
0 Likes
314

Hi  , 

I  am    having requirement  as  below  ,

            1  Read the shopping cart item  ie   ct_item  and  Run all items   and        

            2  Determine and note the product categories-ID and process-ID  of an item  in an internal table.

            3  If  1st item: continue, otherwise: check, whether same product category
              and process-ID are noted already. If no: is the combination of WGR_ID_ADD and
              PROCID_ADD as per table ZSRM_WGR_SORTEN is allowed  and  If no: Display an error message

I  done  coding  as  below  ,  please  check  is  it  correct  and  suggest  if  changes  required,

METHOD check_category.


  DATA: ls_item   
TYPE bbp_pds_sc_item_d,

        ls_message
TYPE bbp_smessages_badi,

        lt_zsrm   
TYPE TABLE  OF  zsrm_wgr_sorten,

        lt_item 
TYPE  bbpt_pd_sc_item_d,

        varcatid
TYPE  comt_category_id,

        varprocind
TYPE zprocind,

        varnumint
TYPE bbp_item_no.



 
SELECT  FROM zsrm_wgr_sorten  INTO  TABLE lt_zsrm

 
FOR  ALL  ENTRIES  IN ct_item

 
WHERE  wgrid_add  =   ct_item-category_id  AND

         procid_add  =  ct_item-procind.



  lt_item  =  ct_item.

 
SORT  lt_item  BY category_id procind.


 
LOOP  AT  lt_item INTO ls_item   WHERE del_ind = space.

   
IF  sy-tabix =  1.

      varcatid  =   ls_item-category_id.

      varprocind =  ls_item-procind.

      varnumint  =  ls_item-number_int.

      CONTINUE.

    ENDIF.


   
READ  TABLE lt_zsrm WITH  KEY  wgrid_add = varcatid

    procid_add =  varprocind
BINARY  SEARCH  TRANSPORTING  NO  FIELDS.


   
IF  sy-subrc  =  0.

     
IF   ls_item-category_id = varcatid AND  ls_item-procind = varprocind .

        ls_message-msgno   =
'002'.

        ls_message-msgty   =
'E'.

        ls_message-msgid   =
'ZSRM_SC'.

        ls_message-msgv1   = ls_item-number_int.

        ls_message-msgv2   = varnumint.

       
APPEND ls_message TO et_messages.

       
CLEAR ls_message.

       
CLEAR varcatid.

       
CLEAR varprocind.

       
CLEAR varnumint.

      ENDIF.

    ENDIF.

    varcatid  =   ls_item-category_id.

    varprocind =  ls_item-procind.

    varnumint  =  ls_item-number_int.


  ENDLOOP.

ENDMETHOD.

Thanks ,

Veeru.

Moderator message: duplicate post, spec dumping

Message was edited by: Thomas Zloch

1 REPLY 1
Read only

Clemenss
Active Contributor
0 Likes
280

Hi veer P,

generate the code and test it.

Regards Clemens