Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Facing issue while creating Purchase Requisition using RAP FACADE for RAP610 On stack scenario #21

Open
vivekaccentt opened this issue Feb 6, 2024 · 2 comments

Comments

@vivekaccentt
Copy link

vivekaccentt commented Feb 6, 2024

Hi team,

I need help.. I am working on RAP 610 scenario and facing issue while running the test class created for creation of Purchase requisition. I am getting following runtime error - Could you please review and help??
I am using S/4HANA on Prem 2023 system, created package with ABAP on cloud SW component version to develop this Embedded Steampunk scenario.

Convert Key statement is going into runtime error -

LOOP AT mapped-purchaserequisition ASSIGNING FIELD-SYMBOL().
CONVERT KEY OF i_purchaserequisitiontp FROM -%pid TO DATA(ls_ctr).
-PurchaseRequisition = ls_ctr-PurchaseRequisition.
ENDLOOP.

Runtime error details:

**Header Information

Short Text An RAP contract has been violated.
Runtime Error BEHAVIOR_CONTRACT_VIOLATION
Program ZCL_TEST_PR_OPERATIONS========CP
Date/Time 07.02.2024 01:47:03 (System)
User MOB31
Client 800
Host S4DEV_S4D_21

What happened?
Error in the ABAP application program.

The current ABAP program "ZCL_TEST_PR_OPERATIONS========CP" had to be terminated because it found a
statement that could not be executed.
An RAP contract has been violated: "CC/C:CONVERT_KEY_NOT_MAPPED".

Affected Behavior Definition / Entity: "R_PURCHASEREQUISITIONTP". Operation / Value: "15C3CA10B0E61EDEB1A5959BF6188D74".
Error analysis
The reason for the runtime error (see the list below) is: (2)
Runtime errors in connection with contract violations can occur for the
following reasons: (0) This contract violation always causes an error
to occur. (1) It is required by the "strict” specification in the
current BO. (2) It is required by the "strict” specification in the BO
that is called. (3) The contract violation occurs in Restricted ABAP.
(4) The corresponding checkpoint group is set to "error". (5) The
violation occurs in a BO enhancement in Restricted ABAP.
The ABAP program must be corrected.

Additional information about the various contract violations:

  • "MISSING_CID":
    Every EML operation that has field %CID (instance-generating
    operations) should be supplied with a unique value in this field.
    ???APDOCU ABAPRAP_BO_CONTRACT
  • "EMPTY_UPDATE":
    Every EML-UPDATE operation should supply at least one non-key field for
    every update record. In the %CONTROLS structure of every update record,
    at least one flag should therefore be set for a non-key field.
  • "DUPLICATE_UPDATE", "DUPLICATE_DELETE", "DUPLICATE_EXECUTE":
  • "AUGM_RELATING":
    A “Modify Augmenting” statement that performs operations on instances
    that are not already included in the original request should relate
    these instances to instances from the original request using the
    RELATING addition, since otherwise responses cannot be assigned.
  • "AUGM_OVERWRITE":
    A “Modify Augmenting” statement must not overwrite any fields from the
    original request. This means that the same %CONTROL flag must not be
    set for the same instance in both the original change and in the
    "Augmenting" change.
  • "DERIVED_TYPE_CONFLICT":
  • "CONVERT_KEY_NOT_MAPPED":
    In the "ADJUST_NUMBERS" phase, a BO with "Late Numbering" must return
    the mapping of all assigned temporary keys (PIDs) to final keys so that
    these can be retrieved using the CONVERT KEY statement.
    ???APDOCU ABENBDL_LATE_NUMBERING
    statement that performs operations on instances that are not already
    included in the original request should relate these instances to
    instances from the original request using the RELATING addition, since
    otherwise responses cannot be assigned.

In case of contract violation "AUGM_OVERWRITE": A “Modify Augmenting”
statement must not overwrite any fields from the original request. This
means that the same %CONTROL flag must not be set for the same instance
in both the original change and in the "Augmenting" change.
Information on where terminated
The termination occurred in ABAP program or include "ZCL_TEST_PR_OPERATIONS========CP", in "IF_OO_ADT_CLASSRUN~MAIN". The
main program was "SAPMSSY1".

In the source code, the termination point is in line 121 of include "ZCL_TEST_PR_OPERATIONS========CM001".
include "ZCL_TEST_PR_OPERATIONS========CM001".**

Source Code of the class:

CLASS zcl_test_pr_operations DEFINITION
PUBLIC
FINAL
CREATE PUBLIC .

PUBLIC SECTION.

INTERFACES if_oo_adt_classrun .

PROTECTED SECTION.
PRIVATE SECTION.
ENDCLASS.

CLASS zcl_test_pr_operations IMPLEMENTATION.

METHOD if_oo_adt_classrun~main.
DATA: purchase_requisitions TYPE TABLE FOR CREATE I_PurchaserequisitionTP,
purchase_requisition TYPE STRUCTURE FOR CREATE I_PurchaserequisitionTP,
purchase_requisition_items TYPE TABLE FOR CREATE i_purchaserequisitionTP_PurchaseRequisitionItem,
purchase_requisition_item TYPE STRUCTURE FOR CREATE i_purchaserequisitiontp\purchaserequisition_purchaserequisitionitem,
purchase_reqn_acct_assgmts TYPE TABLE FOR CREATE I_PurchaseReqnItemTP_PurchaseReqnAcctAssgmt,
purchase_reqn_acct_assgmt TYPE STRUCTURE FOR CREATE I_PurchaseReqnItemTP_PurchaseReqnAcctAssgmt,
purchase_reqn_item_texts TYPE TABLE FOR CREATE I_PurchaseReqnItemTP_PurchaseReqnItemText,
purchase_reqn_item_text TYPE STRUCTURE FOR CREATE I_PurchaseReqnItemTP_PurchaseReqnItemText,
delivery_date TYPE I_PurchaseReqnItemTP-DeliveryDate.

delivery_date = cl_abap_context_info=>get_system_date(  ) + 14.
  • DATA n TYPE i.
    **
  • n += 1.
    "purchase requisition
    purchase_requisition = VALUE #( %cid = 'My%CID_1'
    purchaserequisitiontype = 'NB'
    PurReqnDescription = CONV string( cl_abap_context_info=>get_system_time( ) + 1 ) ) .
    APPEND purchase_requisition TO purchase_requisitions.
"purchase requisition item
purchase_requisition_item = VALUE #(
                                   %cid_ref = 'My%CID_1'
                                   %target  = VALUE #(  (

                                         %cid                            = 'My%ItemCID_1'
                                         plant                           = '4111'
                                         purchaserequisitionitemtext     = 'Test Released APIs 123'
                                           accountassignmentcategory     = 'Q'
                                         requestedquantity               =  '10'
                                         baseunit                        = 'TO'
                                         purchaserequisitionprice        = '200.00'
                                         purreqnitemcurrency             = 'USD'
                                          Material                        = '000000000000000063'
                                         materialgroup                   = '01'
                                         purchasinggroup                 = '001'
  •                                         purchasingorganization          = '4111'
                                           DeliveryDate                    = delivery_date
    
    
    
                                                   ) ) ).
    

    APPEND purchase_requisition_item TO purchase_requisition_items.

    "purchase requisition account assignment
    purchase_reqn_acct_assgmt = VALUE #(
    %cid_ref = 'My%ItemCID_1'
    %target = VALUE #( (
    %cid = 'My%AccntCID_1'

  •                                                  CostCenter = 'JMW-COST'
                                                    GLAccount  = '0000300000'
                                                    quantity   = '10' ) ) ) .
    

    APPEND purchase_reqn_acct_assgmt TO purchase_reqn_acct_assgmts .

    "purchase requisition item text
    purchase_reqn_item_text = VALUE #(
    %cid_ref = 'My%ItemCID_1'
    %target = VALUE #( (
    %cid = 'My%TextCID_1'
    textobjecttype = 'B01'
    language = 'E'
    plainlongtext = 'Commandline test via F9'
    ) ) ) .
    APPEND purchase_reqn_item_text TO purchase_reqn_item_texts.

    "EML deep create statement

    "purchase reqn
    MODIFY ENTITIES OF i_purchaserequisitiontp ENTITY purchaserequisition
    CREATE FIELDS ( purchaserequisitiontype PurReqnDescription )
    WITH purchase_requisitions
    "purchase reqn item
    CREATE BY _purchaserequisitionitem
    FIELDS ( plant
    purchaserequisitionitemtext
    accountassignmentcategory
    requestedquantity
    baseunit
    purchaserequisitionprice
    purreqnitemcurrency
    Material
    materialgroup
    purchasinggroup

  •           purchasingorganization
             DeliveryDate
            )
    WITH purchase_requisition_items
    

    "purchase reqn account assignment
    ENTITY purchaserequisitionitem

    CREATE BY _purchasereqnacctassgmt
    FIELDS (

  •      CostCenter
                 GLAccount
                 Quantity
    
  •               BaseUnit
                 )
        WITH purchase_reqn_acct_assgmts
    "purchase reqn item text
    

    CREATE BY _purchasereqnitemtext
    FIELDS ( plainlongtext )
    WITH purchase_reqn_item_texts

    REPORTED DATA(reported)
    MAPPED DATA(mapped)
    FAILED DATA(failed).

    LOOP AT mapped-purchaserequisition INTO DATA(mapped_pr).
    out->write( |{ mapped_pr-%pid }| ).
    ENDLOOP.

COMMIT ENTITIES
BEGIN RESPONSE OF i_purchaserequisitiontp
FAILED DATA(failed_late)
REPORTED DATA(reported_late).

    LOOP AT mapped-purchaserequisition ASSIGNING FIELD-SYMBOL(<mapped>).
     CONVERT KEY OF i_purchaserequisitiontp FROM <mapped>-%pid TO DATA(ls_ctr).
      <mapped>-PurchaseRequisition = ls_ctr-PurchaseRequisition.
    ENDLOOP.

    IF sy-subrc = 0.
      out->write( | PurchaseRequisition:  { ls_ctr-PurchaseRequisition } | ).
    ELSE.
      out->write( | Error PurchaseRequisition sy-subrc:  { sy-subrc } | ).
    ENDIF.
COMMIT ENTITIES END.

ENDMETHOD.

ENDCLASS.

@vivekaccentt
Copy link
Author

@anfisc - Could you please help me here for this error in RAP610 scenario??

@vivekaccentt
Copy link
Author

Hi Andre,

Just an update on this blog, I debugged the code and found that the data being passed was not correct and due to which exception was being raised. The main problem is that the failed or reported tables don't capture any errors that leads to an exception when CONVERY KEY statement is executed.
I had to debug to check the lt_messages table which contains all the messages in method - if_mm_pur_pr_rap_item_handler~create_item_acc_by_assoc of class CL_MM_PUR_PR_RAP_ITEM_HANDLER

This looks like an SAP bug to me.. Can u please check and guide me accordingly?

I can see some other community posts with same query -

https://community.sap.com/t5/technology-q-a/problem-in-rap-bo-i-purchaserequisitiontp/qaq-p/12736218

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant