Error while executing SAP BAPI_REQUISITION_CHANGE From Uipath Activities

@gabi_verzea
@StefanSchnell
Hello ,
I hope you are doing well!

I need your help in below issue that occurred while calling SAP BAPI_REQUISITION_CHANGE from uipath
error :
Execution stopped unexpectedly :
Message:Element PREQ_NO of container metadata unknown
StackTrace: at SAP.Middleware.Connector.RfcContainerMetadata1.NameToIndex(String elementName) at SAP.Middleware.Connector.RfcDataContainer1.SetValue(String name, Object value)
at UiPath.SAP.BAPI.ConnectionService.SapConnectionService.SapConnectionService.SetInputParams(ICollection1 dataTables, IList1 arguments, IRfcFunction function)
at UiPath.SAP.BAPI.ConnectionService.SapConnectionService.SapConnectionService.ExecuteApi(String apiName, ICollection1 dataTables) at UiPath.SAP.BAPI.Activities.InvokeSapBapi.<>c__DisplayClass26_0.<Execute>b__0(SapBapiTelemetryOperation operation) at UiPath.SAP.BAPI.Telemetry.TelemetryServiceBase.Operation[T](String operationName, String activityId, Func2 method, String bapiName)
at UiPath.SAP.BAPI.Activities.InvokeSapBapi.Execute(CodeActivityContext context)

here are the steps i followed →

  1. Import SAP APPLICATION SCOPE and configure connection – Successful
  2. Invoke SAP BAPI Activity
    a. Called BAPI i.e. BAPI_REQUISTION_GETDETAIL and passed parameters
    please see below screenshot
    image

b. b. As a result I am able to get PR data in DATA Table successful - Req_Cur_Item_dt ( datatable contains PR items details)

  1. Now, I have Req_Cur_Item_dt datatable which Contain PR Requistion Items details.
  2. I have copied this Data table and created another data table with new value for Quantity i.e. 40.0 ( old value is 20.0 ) – req_cur_item_new ( new datatable)
  3. Invoke SAP BAPI Activity
    a. Called Bapi i.e. BAPI_Requisition_Detail with below parameters
    please refer below screenshot

image

  1. When I am executing Step 5 I am getting error as i mentioned at beginning of this post

Note :-> i am using 2.2.5 version of SAP.BAPI.ACTIVITIES

Please help on error

regards
Pratik

Hi @pmexilinx,

the problem is the data structure of the BAPIs you are using.
The BAPI_REQUISITION_GETDETAIL uses a table of type BAPIEBAN where BAPI_REQUISITION_CHANGE uses data type BAPIEBANV for the requisition items.

First columns of BAPIEBAN

First columns of BAPIEBANV

Therefore just copying the data table will not work. You need to map the individual columns.

You can either use transaction SE37 in the SAP GUI to check the structure of the parameters or use “Export Parameters” in UiPath Studio. This will create an Excel with the paramters including the structure of the tables as shown in the screenshot above.
image

Hope this helps.

Thomas

3 Likes

Thank you for the answer, Thomas. I do not have any other ideas at the moment. Pratik, please try what Thomas suggested and let us know if it works.
Thx, Gabi.

1 Like

Sure thomas i will try today and let you know results.

Hi Thomas,

Thanks for your response!
I used your advice and tried to convert into BAPIBANV format and later used as datatable as parameter in BAPI_REQUISTION_CHANGE API.

but i am getting error :

Please see below screenshot of excels where i did mapping along with datatype
Please correct me where i am wrong.

Regards
Pratik

Hi Pratik,
let me see if I got this right - you are trying to pull data from a PR from SAP, update some of the fields, and update the PR, right ?
I am a bit unsure then why there are 2 excel files - “REQ_ITEM_NEW” and “BAPI_REQUISITION_CHANGE”. what is the first excel for ? And are you just outputting them for debugging purposes, to see what data was extracted/modified ? Because, if I understand correctly, you just work with DataTables and update the information there - no need for excel files.
I see the value from the fist excel for purchasing group - 757, but I do not see if in the second one. Is it the same ?
Not sure if this would be an issue, but as the error message says it is trying to convert a number to string, maybe it is worth making sure that you have the correct type for purchasing group as string, not number, in the DT. In excel, I see it is number, not as string, but that’s probably not relevant.

Hi Gabriel,

Excel file (REQ_ITEM_NEW) were used to debug the issues to see what is datatype datable has for all columns. and it is using String as datatype though my screenshot didnt show that so here is another screenshot


Second excel i.e. BAPI_REQUISITION_CHNAGE i got it from RPA BAPI ( see below screenshot ) by exporting it in excel to see sequence of PR columns and datatype


So in my process i am not using any of the two excels for Updating PR records , i am using simply Datatable with rite datatype ( as per BAPI_REQUISITION_CHANGE excel).

When i compare the datatype of PUR_GROUP , it appears to be STRING so i am not sure where i am going wrong ?

Hi Pratik,

I tried to reproduce your problem but did not manage to do so.
What data type did you use for the columns in your data table? In my test I used string and decimal to generate the data table in line with the data types in the Excel.
Conversion to the data structure SAP expects is performed by the connector under the hood depending on the format you provide the data in.

Plese try using only string and decimal as data types when generating the data table for REQUISITION_ITEMS_NEW or REQUISITION_ITEMS_OLD.

If you don’t succeed, please share the XAML. This will make it easier to support you with the troubleshooting.

Thomas

HI Thomas ,

My issue resolved with your first suggestion. here are the steps i did to fix the issues:

  1. create two blank data tables 1. Item_new_dt 2. Item_old_dt
    Item_new_dt → contains the data that need to update in PR
    Item_old_dt → contains the existing data of PR with datatype BAPIBANV

  2. To get data in Item_old_dt , i used BAPI BAPI_REQUISITION_GET_DETAIL and output would be in some Data table say PR_details_dt ( BAPIEBAN datatype )
    Need to map PR_details_dt datatype with Item_old_dt datatype as they have different datatypes in it and that’s the key here.

  3. Source for Item_new_dt → could be your business excel sheet who provided you the data that need to be updates. use that excel sheet and store data in datatable . Make sure all data should be in rite format i.e. String and decimal.

  4. call BAPI i.e. BAPI_REQUISITION_CHANGE and pass three parameters in it

  5. PR number

  6. Items_new_dt

  7. Items_old_dt

along with above parameters , we need to have OUT parameter ( 4th parameter) say Ret_msg . We need to initialize this parameter with “Nothing” to avoid errors.

  1. If we have multiple rows in datatable Items_new_dt , we need to make sure to clear the datatable at the end of loop.

if we follow all above steps , we should be able to update PR

regards
Prtaik Mehta

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.