cancel
Showing results for 
Search instead for 
Did you mean: 

issue using i_purchaserequisitiontp

ok678
Explorer
0 Kudos

hi community,

i wanted to ask something about the behaviour definition i_purchaserequisitiontp. I want to perform a PR in my on-prem system with the mentioned bdef, after taking some parts of the official documentation i've tried to implement it in a custom class but its failing during the COMMIT ENTITIES sequence, I have no idea why.

Edit: i was passing wrong parameters on the functional side por the requisition

CLASS zcl_pr_create DEFINITION<br>  PUBLIC<br>  FINAL<br>  CREATE PUBLIC.<br>  PUBLIC SECTION.<br>    INTERFACES if_oo_adt_classrun.<br>    TYPES:<br>      ty_reported     TYPE RESPONSE FOR REPORTED i_purchaserequisitiontp,<br>      ty_failed       TYPE RESPONSE FOR FAILED  i_purchaserequisitiontp,<br>      ty_mapped       TYPE RESPONSE FOR MAPPED i_purchaserequisitiontp,<br>      ty_t_pr_header  TYPE TABLE FOR CREATE i_purchaserequisitiontp,<br>      ty_t_pr_item    TYPE TABLE FOR CREATE i_purchaserequisitiontp\_PurchaseRequisitionItem,<br>      ty_t_pr_assgnmt TYPE TABLE FOR CREATE I_PurchaseReqnItemTP\_PurchaseReqnAcctAssgmt,<br>      ty_t_pr_addr    TYPE TABLE FOR CREATE I_PurchaseReqnItemTP\_PurchaseReqnDelivAddress,<br>      ty_t_pr_itmtxt  TYPE TABLE FOR CREATE I_PurchaseReqnItemTP\_PurchaseReqnItemText.
<br>    CONSTANTS: lc_cid      TYPE string VALUE 'My%CID_1',<br>               lc_item_cid TYPE string VALUE 'My%ItemCID_1'.
<br>    DATA: it_pr_header  TYPE ty_t_pr_header,<br>          it_pr_item    TYPE ty_t_pr_item,<br>          it_pr_assgnmt TYPE ty_t_pr_assgnmt,<br>          it_pr_addr    TYPE ty_t_pr_addr,<br>          it_pr_itmtxt  TYPE ty_t_pr_itmtxt,<br>          it_reported   TYPE ty_reported,<br>          it_failed     TYPE ty_failed,<br>          it_mapped     TYPE ty_mapped.
<br>    METHODS zpr_create<br>      IMPORTING<br>        VALUE(t_pr_header)   TYPE ty_t_pr_header<br>        VALUE(t_pr_item)     TYPE ty_t_pr_item<br>        VALUE(t_pr_assgnmt)  TYPE ty_t_pr_assgnmt<br>        VALUE(t_pr_addr)     TYPE ty_t_pr_addr<br>        VALUE(t_pr_itmtxt)   TYPE ty_t_pr_itmtxt<br>      EXPORTING<br>        VALUE(reported_data) TYPE ty_reported<br>        VALUE(failed_data)   TYPE ty_failed<br>        VALUE(mapped_data)   TYPE ty_mapped.<br>  PROTECTED SECTION.<br>  PRIVATE SECTION.<br>ENDCLASS.<br><br><br>CLASS zcl_pr_create IMPLEMENTATION.<br><br>  METHOD if_oo_adt_classrun~main.<br>    it_pr_header = VALUE #( ( %cid = lc_cid<br>                              purchaserequisitiontype = 'NB' ) ).
<br>    it_pr_item = VALUE #( ( %cid_ref = lc_cid<br>                            %target = VALUE #( ( %cid                        = lc_item_cid<br>                                                 plant                       = '0001'<br>                                                 purchaserequisitionitemtext = 'Sample Text'<br>                                                 accountassignmentcategory   = 'K'<br>                                                 requestedquantity           = '10.00'<br>                                                 baseunit                    = 'EA'<br>                                                 purchaserequisitionprice    = '10.00'<br>                                                 purreqnitemcurrency         = 'EUR'<br>                                                 materialgroup               = '01'<br>                                                 purchasinggroup             = '001'<br>                                                 purchasingorganization      = '0001'<br>                                                 multipleacctassgmtdistribution = '1' ) ) ) ).
<br>    it_pr_assgnmt = VALUE #( ( %cid_ref = lc_item_cid<br>                               %target = VALUE #( ( costcenter  = 'ABC'<br>                                                    glaccount   = '1234567890'<br>                                                    quantity    = '3.00'<br>                                                    baseunit    = 'EA' )<br>                                                  ( costcenter  = 'DEF'<br>                                                    glaccount   = '1234567890'<br>                                                    quantity    = '7.00'<br>                                                    baseunit    = 'EA' ) ) ) ).
<br>    it_pr_addr = VALUE #( ( %cid_ref = lc_item_cid<br>                            %target = VALUE #( ( businesspartnername1 = 'Name1'<br>                                                 businesspartnername2 = 'Name2'<br>                                                 country = 'AA'<br>                                                 Region  = '11'<br>                                                 PostalCode = '11111' ) ) ) ).
<br>    it_pr_itmtxt = VALUE #( (  %cid_ref = lc_item_cid<br>                               %target = VALUE #( (<br>                                                   textobjecttype = 'B01'<br>                                                   language       = 'E'<br>                                                   plainlongtext  = 'item text 1' )<br>                                                 ( textobjecttype = 'B02'<br>                                                   language       = 'E'<br>                                                   plainlongtext  = 'item text 2' ) ) ) ).
<br>    " Simulacion de un Purchase Requisition<br>    zpr_create( EXPORTING t_pr_header   = it_pr_header<br>                          t_pr_item     = it_pr_item<br>                          t_pr_assgnmt  = it_pr_assgnmt<br>                          t_pr_addr     = it_pr_addr<br>                          t_pr_itmtxt   = it_pr_itmtxt<br>                IMPORTING failed_data   = it_failed<br>                          reported_data = it_reported<br>                          mapped_data   = it_mapped ).
<br>    IF it_failed IS INITIAL.<br>      COMMIT ENTITIES BEGIN IN SIMULATION MODE<br>      RESPONSE OF I_PurchaseRequisitionTP<br>      FAILED DATA(failed)<br>      REPORTED DATA(reported).
<br>      " I_PurchaseRequisitionTP usa late numbering, movemos el preliminary key del interaction<br>      " phase al SAVE sequence<br>      LOOP AT it_mapped-purchaserequisition REFERENCE INTO DATA(lr_pr_mapped).<br>        CONVERT KEY OF I_PurchaseRequisitionTP FROM lr_pr_mapped->%key TO DATA(ls_pr_key).<br>        lr_pr_mapped->PurchaseRequisition = ls_pr_key-PurchaseRequisition.<br>      ENDLOOP.
<br>      LOOP AT it_mapped-purchaserequisitionitem REFERENCE INTO DATA(lr_pri_mapped).<br>        CONVERT KEY OF I_PurchaseReqnItemTP FROM lr_pri_mapped->%key TO DATA(ls_pri_key).<br>        lr_pri_mapped->PurchaseRequisition = ls_pri_key-PurchaseRequisition.<br>      ENDLOOP.<br>      COMMIT ENTITIES END.
<br>      IF failed IS INITIAL.<br>        out->write( 'Success' )->write( ls_pr_key-purchaserequisition ).<br>        out->write( ls_pri_key-purchaserequisitionitem ).<br>      ELSE.<br>        out->write( 'Save sequence failed' ).<br>      ENDIF.<br>    ENDIF.<br>*      out->write( ls_pr_key-PurchaseRequisition ).<br>*      out->write( ls_pri_key-PurchaseRequisitionItem ).<br><br>  ENDMETHOD.
<br><br>  METHOD zpr_create.<br>    MODIFY ENTITIES OF i_purchaserequisitiontp<br>    ENTITY purchaserequisition<br>    CREATE FIELDS ( purchaserequisitiontype )<br>    WITH it_pr_header<br>    CREATE BY \_purchaserequisitionitem<br>    FIELDS ( plant<br>             purchaserequisitionitemtext<br>             accountassignmentcategory<br>             requestedquantity<br>             baseunit<br>             purchaserequisitionprice<br>             purreqnitemcurrency<br>             materialgroup<br>             purchasinggroup<br>             purchasingorganization<br>             multipleacctassgmtdistribution    )<br>    AUTO FILL CID<br>    WITH<br>    it_pr_item<br>    ENTITY purchaserequisitionitem<br>    CREATE BY \_purchasereqnacctassgmt<br>    FIELDS ( costcenter<br>             glaccount<br>             quantity<br>             baseunit )<br>    AUTO FILL CID<br>    WITH it_pr_assgnmt<br>    CREATE BY \_purchasereqndelivaddress<br>    FIELDS ( businesspartnername1<br>             businesspartnername2<br>             country<br>             Region<br>             PostalCode )<br>    AUTO FILL CID<br>    WITH it_pr_addr<br>    CREATE BY \_purchasereqnitemtext<br>    FIELDS ( plainlongtext )<br>    AUTO FILL CID<br>    WITH it_pr_itmtxt<br>      MAPPED mapped_data<br>      FAILED failed_data<br>      REPORTED reported_data.<br>  ENDMETHOD.<br>ENDCLASS.
junwu
Active Contributor
0 Kudos

why not posting the error msg?

Accepted Solutions (0)

Answers (0)