Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 


Step 1: Goto SEGW tcode and Create Project as shown below.

Provide Project Details.

Step 2: Create Two Entity Types. One for PR Header and the other for PR Item.

For PR Header: Provide the following details.

Double click on Properties and Click on Insert Row to add field.

Add PR Number field for PR Header as follows.

For PR Item: Import it from DDIC structure.

Provide ABAP Structure for PR Item.

Select all fields.

Maintain PR Item Number as Key field.

Step 3: Create Association between PR Header and PR Item as shown below.

Provide details as below.

Select Dependent Property as PreqNo.

Click on Finish.

The Association will be displayed as follows.

Step 4: Click on Generate Runtime Objects.

Runtime Classes will be created as follows.


Step 5: Right Click on ZCL_ZPR_CREATE_IN_PARK_DPC_EXT class and select Go to ABAP Workbench.

Step 6: Redefine PRHEADERSET_GET_ENTITY Method

Step 7: Redefine PRITEMSET_GET_ENTITYSET Method

@Note: After redefining the get_entity and get_entityset methods, then get a single record i.e Purchase requisition header with line items.

             So for that, just pass dummy data as shown in the below methods to get the xml structure.

Sample code(Header) :

method PRHEADERSET_GET_ENTITY.

DATA: ls_header TYPE ZCL_ZPR_CREATE_IN_PARK_MPC=>TS_PRHEADER.

    ls_header-preq_no = '1007426'."(Dummy PR)

    ER_ENTITY = ls_header.

Endmethod.

Sample code(Item) :

method PRITEMSET_GET_ENTITYSET.

data: ls_item type  ZCL_ZPR_CREATE_IN_PARK_MPC=>TS_PRITEM.

      ls_item-doc_cat = 'NB'.

      ls_item-batch = 'N'.

      ls_item-currency = 'EUR'.

      APPEND  ls_item to ET_ENTITYSET.

  endmethod.

Step 8: Redefine CREATE_DEEP_ENTITY Method in /IWBEP/IF_MGW_APPL_SRV_RUNTIME.


Step 9: Add following logic in the method.

  METHOD /IWBEP/IF_MGW_APPL_SRV_RUNTIME~CREATE_DEEP_ENTITY.

  TYPES: ty_t_PrItem TYPE STANDARD TABLE OF   ZCL_ZPR_CREATION_PARK_MPC=>TS_PRITEM WITH DEFAULT KEY.

* Represents full PR structure - header with one of more items

  TYPES: BEGIN OF ty_pr.

                   INCLUDE TYPE ZCL_ZPR_CREATION_PARK_MPC=>TS_PRHEADER.

                   TYPES: PrItemSet TYPE ty_t_PrItem,

                END OF ty_pr.

  DATA: ls_pr            TYPE ty_pr,

              t_item          TYPE TABLE  OF bapimereqitemimp,

              wa_item       TYPE bapimereqitemimp,

              t_itemx        TYPE TABLE OF bapimereqitemx,

              wa_itemx     TYPE bapimereqitemx,

              wa_header    TYPE bapimereqheader,

              wa_headerx  TYPE bapimereqheaderx,

              t_return         TYPE TABLE OF bapiret2,

              c_eban          TYPE dokob  VALUE 'EBAN',

              i_dradn         TYPE TABLE OF  drad_n,

              w_dradn       TYPE drad_n,

              lv_objky       TYPE objky.

io_data_provider->read_entry_data( IMPORTING es_data = ls_pr ).

* Assigns the Header details

  wa_header-pr_type            = 'NB'.

  wa_header-create_ind        = 'R'.

  wa_header-item_intvl        = '10'.

wa_header-memory            = 'X'.

  wa_header-park_complete = 'X'.

  wa_header-memorytype     = 'X'. (pass 'X' to these three values to create PR in PARK status)

* Assigns the Header fields to be updated

  wa_headerx-pr_type             = 'X'.

  wa_headerx-create_ind         = 'X'.

  wa_headerx-item_intvl         = 'X'.

  wa_headerx-memory            = 'X'.

  wa_headerx-park_complete = 'X'.

  wa_headerx-memorytype     = 'X'.

* Assigns the Item details

  wa_item-preq_item    = '10'.

  wa_item-pur_group    =  'Z00'.

  wa_item-short_text     = '5-SPEED GEARS'.

  wa_item-material        = 'AM3-400-N'.

  wa_item-plant             = '1000' .

  wa_item-matl_group   = '001'.

  wa_item-quantity        = 12.

  wa_item-preq_price    = 20.

  wa_item-price_unit     = 1.

  wa_item-commitment = 'X'.

  APPEND wa_item TO t_item.

* Assigns the Item fields to be updated

  wa_itemx-preq_item     = '00010'.

  wa_itemx-pur_group    = 'X'.

  wa_itemx-short_text     = 'X'.

  wa_itemx-material        = 'X'.

  wa_itemx-plant             = 'X' .

  wa_itemx-matl_group   = 'X'.

  wa_itemx-quantity        = 'X'.

  wa_itemx-preq_price    = 'X'.

  wa_itemx-price_unit     = 'X'.

  wa_itemx-commitment = 'X'.

  APPEND wa_itemx TO t_itemx.

* Create the PR in PARK status using BAPI

  CALL FUNCTION 'BAPI_PR_CREATE'

    EXPORTING

      prheader      = wa_header

      prheaderx    = wa_headerx

    TABLES

      return          = t_return

      pritem         = t_item

      pritemx       = t_itemx

    EXCEPTIONS

      OTHERS    = 1.

* To Commit

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.

* To Read PR Number

DATA(ts_return) = t_return[ 1 ].

ls_pr-preq_no = ts_return-message.

* To Read Item Number of PR

DATA(w_item) = t_item[ 1 ].

* Concatenate PR number with Item number

lv_objky = |{ '00' }| && |{ ts_return-MESSAGE_V1 }| && |{ w_item-PREQ_ITEM }|.

* To fetch DMS Document number based on Quotation ID

SELECT SINGLE DMS_DOC_ID from ZQUOT_DETAILS INTO @DATA(lv_dms_no) WHERE QUOT_ID = '1234'.

  w_dradn-DOKAR  = 'DOC'.

*  w_dradn-DOKNR = lv_dms_no.

  w_dradn-DOKNR = '10000000212'.

  w_dradn-dokvr      = '00'.

  w_dradn-doktl       = '000'.

  w_dradn-dokob     = c_eban.

  w_dradn-obzae      = '0000'.

  w_dradn-objky      = lv_objky.

  APPEND w_dradn  TO i_dradn.

* FM to attach DMS document to the item of created PR

CALL FUNCTION 'DOKUMENTZUORDNUNGEN_BUCHEN'

      IN UPDATE TASK

      EXPORTING

        ob         = c_eban

        objky    = lv_objky

      TABLES

        savdrad = i_dradn.

* Commit

     CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

      EXPORTING

        wait = 'X'.

      REFRESH:  i_dradn.

* To display the Message

    copy_data_to_ref(

    EXPORTING

     is_data =  ls_pr"t_return

   CHANGING

     cr_data = er_deep_entity

).

  endmethod.

***Service Maintainance & Registration******

Step 10: Goto Tcode /n/iwfnd/maint_service and Add Service.

Step 11: Provide System Alias and Click on Get Services.

               Select Our Created Service and click on Add Selected Service.

Step 12: Go Back and Click on SAP Gateway Client.

Step 13: Provide the following URL, Select GET and click on EXECUTE to get the sample XML of PR.


Step 14: Click on Use as Request and then select POST and EXECUTE it.

PR will be Created Successfully in PARK Status along with an attachment in Item Level.


Step 15: Goto ME51N tcode and Provide the Created PR Number.

               So as shown it is created in PARKED status.

You can also check it in EBAN table.(MemoryType value will be "P" for the above Purchase Requisition Number).

Select Item of  PR and click on Documents Icon to display the attached Document.

Thanks & Regards,

Naveena M.

2 Comments
Labels in this area