Hello Everybody.
In these day i’ve started to use sap accelerator pack.
In these pack i found the workflof named SRC_RFC_READ_TABLEv2.2
I understand the logic inside and it’s perfect for my use because i have a lot of process need to read data inside sap tables.
I don’t understand how to preparer this mandatory value:
In your Foundation pack for Accelerators for SAP ECC you offer in SRC_Common two workflows:
SRC_RFC_READ_TABLE_v2.2.xaml
Use RFM RFC_READ_TABLE.
SRC_BBP_RFC_READ_TABLE_v2.2.xaml
Use RFM BBP_RFC_READ_TABLE. This RFM is only available if the Add-On for Electronic Commerce is installed. As far as I can see in the signature, it is only a copy of RFC_READ_TABLE, maybe different authorizations.
Both workflows call an RFM with your Invoke SAP BAPI activity.
I would say: Ouch. This is against the specification. I suggest replacing that with a coded approach, similar here, because NCo is available. Otherwise the problem can arise, that support for this approach must be provided and that can become “rough terrain”.
Hope you understand my concerns.
I recommend you to do not use this approach, because the call of RFMs does not comply with the BAPI specification. Use an Invoke Code activity with e.g. the following C# code:
//-RFM Code Generator Begin (C#)----------------------------------------
RfcConfigParameters cfgParams = new RfcConfigParameters();
cfgParams.Add("NAME", "Test");
cfgParams.Add("ASHOST", "YourHost");
cfgParams.Add("CLIENT", "YourClient");
cfgParams.Add("USER", "YourUser");
cfgParams.Add("PASSWD", "YourPassword");
cfgParams.Add("LANGUAGE", "EN");
string strWA;
try {
RfcDestination destination = RfcDestinationManager.GetDestination(cfgParams);
IRfcFunction rfcFunction = destination.Repository.CreateFunction("RFC_READ_TABLE");
//-Tables-------------------------------------------------------------
IRfcTable tblDATA = rfcFunction.GetTable("DATA");
IRfcTable tblFIELDS = rfcFunction.GetTable("FIELDS");
IRfcTable tblOPTIONS = rfcFunction.GetTable("OPTIONS");
//-Import-------------------------------------------------------------
rfcFunction.SetValue("DELIMITER", "~");
rfcFunction.SetValue("QUERY_TABLE", "KNA1");
//Add your fields here
//tblFIELDS.Append();
//tblFIELDS.SetValue("FIELDNAME", "");
tblOPTIONS.Append();
tblOPTIONS.SetValue("TEXT", "ERDAT = '20210202'");
//-Invoke-------------------------------------------------------------
rfcFunction.Invoke(destination);
foreach(var Record in tblDATA) {
strWA += Record.GetString("WA") + Environment.NewLine;
}
//In the string strWA is now the result available
} catch(Exception ex) {
Console.WriteLine(ex.Message);
}
//-RFM Code Generator End-----------------------------------------------
Important hint: The maximum length of the result is 512 characters. Make sure that you only select the fields you need and that they do not exceed this length in total.
Thanks for your answers! i really appreciate it.
Let me get this straight.
The method inside uipath accelerator sap (RFC_READ_TABLE) it’s not correct because doesn’t comply with bapi?
2.
In uipath there is activy sap bapi. With that i can use sapapplication scope and invoke bapi. I don’t use that? and if yes why?
3.
With your code in C# i saw there is input parameters for login , if i login with SS0 how can i change that parameters?
Yes, RFC_READ_TABLE or BBP_RFC_READ_TABLE are not BAPIs, they are RFMs.
In the interface e.g. you see exceptions and these are not allowed with BAPIs. If an error occurs in an BAPI you must use return structure BAPIRET2.
You can find more information about the difference between BAPI and RFM here.
You can use that activity with BAPIs without any problems, but not with RFMs. But…
I tried to input another RFM and …
I checked RFC_SYSTEM_INFO with RFCSYSID from RFCSI_Export structure and I got the expected result.
Boah ey!
It seems that the activity should not be called Invoke SAP BAPI but Invoke SAP RFM.
Now I have to sit down for a while. I would never have assumed that this was possible.
Thank you very much L., your question offers us new possibilities and puts my previous comments into another perspective. This requires further analysis.
Sure, as far as I know, look at the Snc* config parameters. I know it works but unfortunately I never used that.
Great!
yes it run because i can download data from a very low populate table because i can only insert the name of the table on QUERY NAME. otherwise too much results!
I need to undertand how to create datatable to transfer DATA, FIELDS and OPTIONS.
If you have any experience with this problem can you help me? i can’t find any solution on google and the documentation on uipath is very poor about it.
Add a row to your OPTIONS data table. In this row you can the where clause, in your case ERDAT=‘20210202’. The max length is here 72 characters. If you need more options add more rows.
Open the Invoke SAP BAPI activity and insert RFC_READ_TABLE. Add the parameter DELIMITER. For the output add with Strg+K a DATA table, in this example dt_DATA.
As I wrote above, the return field WA allows in maximum 512 characters. So it is necessary for the KNA1 table to define the fields you need. To realize that add a data table FIELDS.
Add a column with the name FIELDNAME.
Add one ore more rows of the fields you need from your table.
On this way you can use RFC_READ_TABLE with the Invoke SAP BAPI activity.
The field KUNNR at position 2 has a length of 10 characters, this is a unicode system so you must divide the the length with 2. Try your KUNNR 4965 with the leading zeros, e.g. 0000004965.
The field SPRAS at position 53 has a length of 1 character. Try it with I instead IT. You can find all language keys in table T002.
BELNR (Accounting document number) is in my case not part of this table. Try your example with NAME1 or ORT01.
One last question.
Do you have some link to understand how to build a query with this method?
ex:
How can i request in KNA1 the customers created in a period?
ex. created from 20210101 to 2021031?
The query in the options table is like the WHERE clause in SQL, but in this case it called Open SQL. Look at ABAP documentation at SQL condition (sql_cond).
To solve your requirement try in your options
ERDAT > ‘20210101’ AND ERDAT < ‘20210301’
Ok.
I understand and i read some info on google with SQL condition.
For understand in a better way i would know how to:
Pass a variable inside option.
I try with
assign a variable like this:
{“ERDAT <= “+datetime.now.AddYears(-2).ToString(“yyyyMMdd”)+” AND KTOKK = ‘ITLO’ AND LOEVM = ‘X’”}
2 the result in uipath from SAP is zero.
The datatable variable uipath send to SAP is
[TEXT
ERDAT <= 20190402 AND KTOKK = ‘ITLO’ AND LOEVM = ‘X’
]
3 i see the field ERDAT with date doesn’t have ’ ’ . is this the problem? how can i fix it?
Another point is:
if a want to search lot of customer in a table how can i pass these customercode
?
i try with
the add data row contain customer code
The code give me error
RFC_READ_TABLE: A condition specified dynamically has an unexpected format.
and the variable uipath pass to sap is
the last question is:
how can i check in a table in options if a fields it’s empty?
ex: in LFA1 i want to search all suplliers without block
with this code sap give me error
OEVM != 'X
what is the wright way?
I don’t know how to say thank you for your precious help.
I programmed my own function module to test the situation. As table TA_OPTIONS from the type RFC_DB_OPT and it delivers as export parameter the text. These data types are the same as in the RFM RFC_READ_TABLE.
FUNCTION Z_LORIS.
*"----------------------------------------------------------------------
*"*"Local Interface:
*" EXPORTING
*" VALUE(EX_OPTIONS_TEXT) TYPE SO_TEXT
*" TABLES
*" TA_OPTIONS STRUCTURE RFC_DB_OPT
*"----------------------------------------------------------------------
DATA:
strOptions TYPE RFC_DB_OPT
.
LOOP AT TA_OPTIONS INTO strOptions.
EX_OPTIONS_TEXT = strOptions-TEXT.
ENDLOOP.
ENDFUNCTION.
I tried a part of your example and it works perfect.
And I tried your full example and it works perfect too.
{"ERDAT = '" & datetime.now.AddYears(-2).ToString(“yyyyMMdd”) & "' AND KTOKK = 'ITLO' AND LOEVM = 'X'"}
To use different KUNNR you must set in the options table
{"KUNNR = '0000004711' OR KUNNR = '0000004712'"}
To check if a character field is empty in Open SQL try