cancel
Showing results for 
Search instead for 
Did you mean: 

RAP - Possible bug in standard API i_purchaserequisitiontp?

diego_valentino
Explorer

Hi,

Today, I implemented the code on tutorial https://developers.sap.com/tutorials/abap-s4hanacloud-procurement-purchasereq-shop.html

The purpose of this tutorial is to create a custom RAP business object to trigger purchase requisitions API

I implemented the code in a system with S/4 HANA Cloud 2208, development tenant.

I completed all the steps in the tutorial. I was able to execute the app. But when I pressed the create button on the Fiori temporary app, I got an error with text: "An exception was rised"

image

I set a breakpoint after the MODIFY ENTITIES sentence, and noticed REPORTED and FAILED tables are empty
image

I also surrounded the MODIFY ENTITIES by a TRY ENDTRY sentence, but didn't catch any exception.

Reviewing the Feed Reader I noticed a gateway error was triggered. The text is "Frontend Error: An exception was raised, Service: /SAP/-ZSB_SHOP_001-0001"


image

Debugging the code I noticed a message error is triggered in class CL_BP_R_PURCHASEREQNTP. The error is caused because plant 1010 doesn't exist in my system.

Does anyone know why the sentence MODIFY ENTITIES i_purchaserequisitiontp doesn't return the errors triggered by inside class CL_BP_R_PURCHASEREQNTP, but instead a Gateway error is triggered. Do you know some other way to catch this error?


Just as a reference, this is the code where the error is triggered:

      TRY.
        MODIFY ENTITIES OF i_purchaserequisitiontp

          ENTITY purchaserequisition
            CREATE FIELDS ( purchaserequisitiontype )
            WITH VALUE #(  ( %cid                    = 'My%CID_1'
                             purchaserequisitiontype = 'NB' ) )

            CREATE BY \_purchaserequisitionitem
            FIELDS (    plant
                        purchaserequisitionitemtext
                        accountassignmentcategory
                        requestedquantity
                        baseunit
                        purchaserequisitionprice
                        purreqnitemcurrency
                        materialgroup
                        purchasinggroup
                        purchasingorganization
*                           MultipleAcctAssgmtDistribution
                    )
            WITH VALUE #(
                    (    %cid_ref = 'My%CID_1'
                         %target = VALUE #(
                                          (  %cid                            = 'My%ItemCID_1'
                                              plant                           = '1010'
                                              purchaserequisitionitemtext     = 'created from PAAS API'
                                                accountassignmentcategory     = 'U'
                                              requestedquantity               = '8.00'
                                              baseunit                        = 'EA'
                                              purchaserequisitionprice        = '10.00'
                                              purreqnitemcurrency             = 'EUR'
                                              materialgroup                   = 'A001'
                                              purchasinggroup                 = '001'
                                              purchasingorganization          = '1010'

                                              )
                                          )
                      )
                    )

          ENTITY purchaserequisitionitem
            CREATE BY \_purchasereqnacctassgmt
                FIELDS (    CostCenter
                            GLAccount
                            Quantity
                            BaseUnit )
                WITH VALUE #( (   %cid_ref = 'My%ItemCID_1'
                                  %target  = VALUE #( ( %cid = 'MyTargetCID_1'
                                                CostCenter   = 'JMW-COST'
                                                GLAccount    = '0000400000' ) ) ) )
            CREATE BY \_purchasereqnitemtext
            FIELDS ( plainlongtext )
            WITH VALUE #(  (   %cid_ref = 'My%ItemCID_1'
                               %target  = VALUE #( (
                                                    %cid = 'MyTargetCID_2'
                                                    textobjecttype = 'B01'
                                                    language       = 'E'
                                                    plainlongtext  = 'item text created from PAAS API'
                                                  ) (
                                                    %cid = 'MyTargetCID_3'
                                                    textobjecttype = 'B02'
                                                    language       = 'E'
                                                    plainlongtext  = 'item2 text created from PAAS API'
                                                  ) )
                        )   )
              REPORTED DATA(ls_pr_reported)
              MAPPED DATA(ls_pr_mapped)
              FAILED DATA(ls_pr_failed).

        zbp_i_online_shop_001=>cv_pr_mapped = ls_pr_mapped.
      CATCH cx_root INTO DATA(lx_exception).

      ENDTRY.<br>

Regards.

View Entire Topic
jessie1215
Discoverer
0 Kudos

I also implemented calls to the API I_PurchaserequisitionTP, but after the MODIFY ENTITIES OF i_purchaserequisitiontp it retured an empty %pid:

and in the additional save method, a dump occured when convert the %PID to the final key:

Could anyone help on this issue? Thanks!

Jessie

chinghongchong
Explorer
0 Kudos
Hi I face the same issue... any luck on this?
Ruchi_Dobriyal
Associate
Associate
0 Kudos
Please check note 3007829 - ABAP: CONVERT KEY Statement Fails with Expression