PROBLEM WITH BAPI RFC_READ_TABLE

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:

Someone can explain me how to do?

for example i need to receive from bapi the table KNA1 for customers create on 02.02.2021 (field name sap is ERDAT)

Thank you!!

1 Like

@LevKushnir

Hello Lev,

I want to bring that post into your attention.

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.

Best regards
Stefan

1 Like

@l.sambinelli

Hello L,

welcome in the UiPath Community.

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.

Hope this helps you.

Best regards
Stefan

1 Like

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?

Thanks a lot for your answers and your code!

1 Like

@l.sambinelli

Hello L,
to your questions:

  1. 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.
    image
    You can find more information about the difference between BAPI and RFM here.

  2. You can use that activity with BAPIs without any problems, but not with RFMs. But…
    I tried to input another RFM and …


    … it works. :crazy_face: That’s a thing.
    Now I tried more and it works with RFC also.

    I checked RFC_SYSTEM_INFO with RFCSYSID from RFCSI_Export structure and I got the expected result.
    image
    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.

  3. Sure, as far as I know, look at the Snc* config parameters. I know it works but unfortunately I never used that.

Best regards
Stefan

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.

1 Like

Hello L.,

here the answer of your question.

Define your SAP Application Scope and add inside the Do sequence a Try Catch.

Add a data table for the OPTIONS parameter of the RFC_READ_TABLE RFM and add a column at this table with the name TEXT.

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.

image

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.

With the following loop I write the output.

image

I tried that with table USR02 and the option BNAME = ‘BCUSER’ because the table KNA1 is on my test system not available.

image

Here the complete workflow.

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.

image

Add a column with the name FIELDNAME.

image

Add one ore more rows of the fields you need from your table.

image

On this way you can use RFC_READ_TABLE with the Invoke SAP BAPI activity. :grin:

Best regards
Stefan

Thank you very much!
you are my hero!!!

i follow your code and it run!!!

But i have this problem.
If i want to extract some data from table KNA1 i don’t have any results


my input is these:

and these
image

if i try with other simple table maybe T005T for all nation IT
image
datatable is populated

i think the problem is inside the dt_options. what is my mistake???

thankssss
Loris

@l.sambinelli

Hello Loris,
here the fields of the KNA1 table (General Data in Customer Master):

-------------------------------------------------------------------------------------------------------------------
|Table Name |Field Name       |Table position|Key field|Data element            |Check table     |ABAP type|Length|
-------------------------------------------------------------------------------------------------------------------
|KNA1       |MANDT            |0001          |X        |MANDT                   |T000            |C        |000006|
|KNA1       |KUNNR            |0002          |X        |KUNNR                   |                |C        |000020|
|KNA1       |LAND1            |0003          |         |LAND1_GP                |T005            |C        |000006|
|KNA1       |NAME1            |0004          |         |NAME1_GP                |                |C        |000070|
|KNA1       |NAME2            |0005          |         |NAME2_GP                |                |C        |000070|
|KNA1       |ORT01            |0006          |         |ORT01_GP                |                |C        |000070|
|KNA1       |PSTLZ            |0007          |         |PSTLZ                   |                |C        |000020|
|KNA1       |REGIO            |0008          |         |REGIO                   |T005S           |C        |000006|
|KNA1       |SORTL            |0009          |         |SORTL                   |                |C        |000020|
|KNA1       |STRAS            |0010          |         |STRAS_GP                |                |C        |000070|
|KNA1       |TELF1            |0011          |         |TELF1                   |                |C        |000032|
|KNA1       |TELFX            |0012          |         |TELFX                   |                |C        |000062|
|KNA1       |XCPDK            |0013          |         |XCPDK                   |                |C        |000002|
|KNA1       |ADRNR            |0014          |         |ADRNR                   |                |C        |000020|
|KNA1       |MCOD1            |0015          |         |MCDD1                   |                |C        |000050|
|KNA1       |MCOD2            |0016          |         |MCDD2                   |                |C        |000050|
|KNA1       |MCOD3            |0017          |         |MCDD3                   |                |C        |000050|
|KNA1       |.INCLUDE         |0018          |         |                        |                |         |000000|
|KNA1       |ANRED            |0019          |         |ANRED                   |                |C        |000030|
|KNA1       |AUFSD            |0020          |         |AUFSD_X                 |TVAST           |C        |000004|
|KNA1       |BAHNE            |0021          |         |BAHNE                   |                |C        |000050|
|KNA1       |BAHNS            |0022          |         |BAHNS                   |                |C        |000050|
|KNA1       |BBBNR            |0023          |         |BBBNR                   |                |N        |000014|
|KNA1       |BBSNR            |0024          |         |BBSNR                   |                |N        |000010|
|KNA1       |BEGRU            |0025          |         |BRGRU                   |*               |C        |000008|
|KNA1       |BRSCH            |0026          |         |BRSCH                   |T016            |C        |000008|
|KNA1       |BUBKZ            |0027          |         |BUBKZ                   |                |N        |000002|
|KNA1       |DATLT            |0028          |         |DATLT                   |                |C        |000028|
|KNA1       |ERDAT            |0029          |         |ERDAT_RF                |                |D        |000016|
|KNA1       |ERNAM            |0030          |         |ERNAM_RF                |                |C        |000024|
|KNA1       |EXABL            |0031          |         |EXABL                   |                |C        |000002|
|KNA1       |FAKSD            |0032          |         |FAKSD_X                 |TVFS            |C        |000004|
|KNA1       |FISKN            |0033          |         |FISKN_D                 |KNA1            |C        |000020|
|KNA1       |KNAZK            |0034          |         |KNAZK                   |TFACD           |C        |000004|
|KNA1       |KNRZA            |0035          |         |KNRZA                   |KNA1            |C        |000020|
|KNA1       |KONZS            |0036          |         |KONZS                   |                |C        |000020|
|KNA1       |KTOKD            |0037          |         |KTOKD                   |T077D           |C        |000008|
|KNA1       |KUKLA            |0038          |         |KUKLA                   |TKUKL           |C        |000004|
|KNA1       |LIFNR            |0039          |         |LIFNR                   |LFA1            |C        |000020|
|KNA1       |LIFSD            |0040          |         |LIFSD_X                 |TVLS            |C        |000004|
|KNA1       |LOCCO            |0041          |         |LOCCO                   |                |C        |000020|
|KNA1       |LOEVM            |0042          |         |LOEVM_X                 |                |C        |000002|
|KNA1       |NAME3            |0043          |         |NAME3_GP                |                |C        |000070|
|KNA1       |NAME4            |0044          |         |NAME4_GP                |                |C        |000070|
|KNA1       |NIELS            |0045          |         |NIELS                   |TNLS            |C        |000004|
|KNA1       |ORT02            |0046          |         |ORT02_GP                |                |C        |000070|
|KNA1       |PFACH            |0047          |         |PFACH                   |                |C        |000020|
|KNA1       |PSTL2            |0048          |         |PSTL2                   |                |C        |000020|
|KNA1       |COUNC            |0049          |         |COUNC                   |T005E           |C        |000006|
|KNA1       |CITYC            |0050          |         |CITYC                   |T005G           |C        |000008|
|KNA1       |RPMKR            |0051          |         |RPMKR                   |                |C        |000010|
|KNA1       |SPERR            |0052          |         |SPERB_X                 |                |C        |000002|
|KNA1       |SPRAS            |0053          |         |SPRAS                   |T002            |C        |000002|
|KNA1       |STCD1            |0054          |         |STCD1                   |                |C        |000032|
|KNA1       |STCD2            |0055          |         |STCD2                   |                |C        |000022|
|KNA1       |STKZA            |0056          |         |STKZA                   |                |C        |000002|
|KNA1       |STKZU            |0057          |         |STKZU                   |                |C        |000002|
|KNA1       |TELBX            |0058          |         |TELBX                   |                |C        |000030|
|KNA1       |TELF2            |0059          |         |TELF2                   |                |C        |000032|
|KNA1       |TELTX            |0060          |         |TELTX                   |                |C        |000060|
|KNA1       |TELX1            |0061          |         |TELX1                   |                |C        |000060|
|KNA1       |LZONE            |0062          |         |LZONE                   |TZONE           |C        |000020|
|KNA1       |XZEMP            |0063          |         |XREGU                   |                |C        |000002|
|KNA1       |VBUND            |0064          |         |RASSC                   |T880            |C        |000012|
|KNA1       |STCEG            |0065          |         |STCEG                   |                |C        |000040|
|KNA1       |DEAR1            |0066          |         |DEAR1                   |                |C        |000002|
|KNA1       |DEAR2            |0067          |         |DEAR2                   |                |C        |000002|
|KNA1       |DEAR3            |0068          |         |DEAR3                   |                |C        |000002|
|KNA1       |DEAR4            |0069          |         |DEAR4                   |                |C        |000002|
|KNA1       |DEAR5            |0070          |         |DEAR5                   |                |C        |000002|
|KNA1       |GFORM            |0071          |         |GFORM                   |TVGF            |C        |000004|
|KNA1       |BRAN1            |0072          |         |BRAN1_D                 |TBRC            |C        |000020|
|KNA1       |BRAN2            |0073          |         |BRAN2                   |TBRC            |C        |000020|
|KNA1       |BRAN3            |0074          |         |BRAN3                   |TBRC            |C        |000020|
|KNA1       |BRAN4            |0075          |         |BRAN4                   |TBRC            |C        |000020|
|KNA1       |BRAN5            |0076          |         |BRAN5                   |TBRC            |C        |000020|
|KNA1       |EKONT            |0077          |         |EKONT                   |VBUK            |C        |000020|
|KNA1       |UMSAT            |0078          |         |UMSAT                   |                |P        |000005|
|KNA1       |UMJAH            |0079          |         |UMJAH                   |                |N        |000008|
|KNA1       |UWAER            |0080          |         |UWAER                   |TCURC           |C        |000010|
|KNA1       |JMZAH            |0081          |         |JMZAH                   |                |N        |000012|
|KNA1       |JMJAH            |0082          |         |JMJAH                   |                |N        |000008|
|KNA1       |KATR1            |0083          |         |KATR1                   |TVK1            |C        |000004|
|KNA1       |KATR2            |0084          |         |KATR2                   |TVK2            |C        |000004|
|KNA1       |KATR3            |0085          |         |KATR3                   |TVK3            |C        |000004|
|KNA1       |KATR4            |0086          |         |KATR4                   |TVK4            |C        |000004|
|KNA1       |KATR5            |0087          |         |KATR5                   |TVK5            |C        |000004|
|KNA1       |KATR6            |0088          |         |KATR6                   |TVK6            |C        |000006|
|KNA1       |KATR7            |0089          |         |KATR7                   |TVK7            |C        |000006|
|KNA1       |KATR8            |0090          |         |KATR8                   |TVK8            |C        |000006|
|KNA1       |KATR9            |0091          |         |KATR9                   |TVK9            |C        |000006|
|KNA1       |KATR10           |0092          |         |KATR10                  |TVK0            |C        |000006|
|KNA1       |STKZN            |0093          |         |STKZN                   |                |C        |000002|
|KNA1       |UMSA1            |0094          |         |UMSA1                   |                |P        |000008|
|KNA1       |TXJCD            |0095          |         |TXJCD                   |TTXJ            |C        |000030|
|KNA1       |PERIV            |0096          |         |PERIV                   |T009            |C        |000004|
|KNA1       |ABRVW            |0097          |         |ABRVW                   |TVLV            |C        |000006|
|KNA1       |INSPBYDEBI       |0098          |         |QINSPBYDEB              |                |C        |000002|
|KNA1       |INSPATDEBI       |0099          |         |QINSPATDEB              |                |C        |000002|
|KNA1       |KTOCD            |0100          |         |KTOCD                   |T077D           |C        |000008|
|KNA1       |PFORT            |0101          |         |PFORT_GP                |                |C        |000070|
|KNA1       |WERKS            |0102          |         |WERKS_D                 |T001W           |C        |000008|
|KNA1       |DTAMS            |0103          |         |DTAMS                   |                |C        |000002|
|KNA1       |DTAWS            |0104          |         |DTAWS                   |*               |C        |000004|
|KNA1       |DUEFL            |0105          |         |DUEFL_BKPF              |                |C        |000002|
|KNA1       |HZUOR            |0106          |         |HZUOR                   |                |N        |000004|
|KNA1       |SPERZ            |0107          |         |SPERZ                   |                |C        |000002|
|KNA1       |ETIKG            |0108          |         |ETIKG                   |TWEK            |C        |000020|
|KNA1       |CIVVE            |0109          |         |CIVVE                   |                |C        |000002|
|KNA1       |MILVE            |0110          |         |MILVE                   |                |C        |000002|
|KNA1       |KDKG1            |0111          |         |KDKG1                   |TVKGG           |C        |000004|
|KNA1       |KDKG2            |0112          |         |KDKG2                   |TVKGG           |C        |000004|
|KNA1       |KDKG3            |0113          |         |KDKG3                   |TVKGG           |C        |000004|
|KNA1       |KDKG4            |0114          |         |KDKG4                   |TVKGG           |C        |000004|
|KNA1       |KDKG5            |0115          |         |KDKG5                   |TVKGG           |C        |000004|
|KNA1       |XKNZA            |0116          |         |XKNZA                   |                |C        |000002|
|KNA1       |FITYP            |0117          |         |J_1AFITP_D              |J_1AFITP        |C        |000004|
|KNA1       |STCDT            |0118          |         |J_1ATOID                |J_1ATODC        |C        |000004|
|KNA1       |STCD3            |0119          |         |STCD3                   |                |C        |000036|
|KNA1       |STCD4            |0120          |         |STCD4                   |                |C        |000036|
|KNA1       |STCD5            |0121          |         |STCD5                   |                |C        |000120|
|KNA1       |XICMS            |0122          |         |J_1BTCICMS              |                |C        |000002|
|KNA1       |XXIPI            |0123          |         |J_1BTCIPI               |                |C        |000002|
|KNA1       |XSUBT            |0124          |         |J_1BTCST                |J_1BTXSTG       |C        |000006|
|KNA1       |CFOPC            |0125          |         |J_1BINDUS1              |                |C        |000004|
|KNA1       |TXLW1            |0126          |         |J_1BTAXLW1              |J_1BATL1        |C        |000006|
|KNA1       |TXLW2            |0127          |         |J_1BTAXLW2              |J_1BATL2        |C        |000006|
|KNA1       |CCC01            |0128          |         |CCC01                   |                |C        |000002|
|KNA1       |CCC02            |0129          |         |CCC02                   |                |C        |000002|
|KNA1       |CCC03            |0130          |         |CCC03                   |                |C        |000002|
|KNA1       |CCC04            |0131          |         |CCC04                   |                |C        |000002|
|KNA1       |CASSD            |0132          |         |CASSD_X                 |                |C        |000004|
|KNA1       |KNURL            |0133          |         |URL                     |                |C        |000264|
|KNA1       |J_1KFREPRE       |0134          |         |REPRES                  |                |C        |000020|
|KNA1       |J_1KFTBUS        |0135          |         |GESTYP                  |BUSTYPE         |C        |000060|
|KNA1       |J_1KFTIND        |0136          |         |INDTYP                  |INDUSTYPE       |C        |000060|
|KNA1       |CONFS            |0137          |         |CONFS_X                 |                |C        |000002|
|KNA1       |UPDAT            |0138          |         |UPDAT_RF                |                |D        |000016|
|KNA1       |UPTIM            |0139          |         |UPTIM_RF                |                |T        |000012|
|KNA1       |NODEL            |0140          |         |NODEL_X                 |                |C        |000002|
|KNA1       |DEAR6            |0141          |         |DEAR6                   |                |C        |000002|
|KNA1       |CVP_XBLCK        |0142          |         |CVP_XBLCK               |                |C        |000002|
|KNA1       |.INCLUDE         |0143          |         |                        |                |         |000000|
|KNA1       |SUFRAMA          |0144          |         |J_1BSUFRAMA             |                |C        |000018|
|KNA1       |RG               |0145          |         |J_1BRG                  |                |C        |000022|
|KNA1       |EXP              |0146          |         |J_1BEXP                 |                |C        |000006|
|KNA1       |UF               |0147          |         |J_1BUF                  |                |C        |000004|
|KNA1       |RGDATE           |0148          |         |J_1BRGDATE              |                |D        |000016|
|KNA1       |RIC              |0149          |         |J_1BRIC                 |                |N        |000022|
|KNA1       |RNE              |0150          |         |J_1BRNE                 |                |C        |000020|
|KNA1       |RNEDATE          |0151          |         |J_1BRNEDATE             |                |D        |000016|
|KNA1       |CNAE             |0152          |         |J_1BCNAE                |J_1BTCNAE       |C        |000014|
|KNA1       |LEGALNAT         |0153          |         |J_1BLEGALNAT            |J_1BTLEGALNAT   |N        |000008|
|KNA1       |CRTN             |0154          |         |J_1BCRTN                |                |C        |000002|
|KNA1       |ICMSTAXPAY       |0155          |         |J_1BICMSTAXPAY          |J_1BTICMSTAXPAY |C        |000004|
|KNA1       |INDTYP           |0156          |         |J_1BINDTYP              |J_1BTINDTYP     |C        |000004|
|KNA1       |TDT              |0157          |         |J_1BTDT                 |J_1BTTDT        |C        |000004|
|KNA1       |COMSIZE          |0158          |         |J_1BCOMSIZE             |J_1BTCOMSIZE    |C        |000004|
|KNA1       |DECREGPC         |0159          |         |J_1BDECREGPC            |J_1BTDECREGPC   |C        |000004|
|KNA1       |.INCLU--AP       |0160          |         |                        |                |         |000000|
|KNA1       |.INCLUDE         |0161          |         |                        |                |         |000000|
|KNA1       |/VSO/R_PALHGT    |0162          |         |/VSO/R_PAL_BIN_HGT      |                |P        |000007|
|KNA1       |/VSO/R_PAL_UL    |0163          |         |/VSO/R_PAL_UNIT_L       |T006            |C        |000006|
|KNA1       |/VSO/R_PK_MAT    |0164          |         |/VSO/M_PACK_BY_MAT      |                |C        |000002|
|KNA1       |/VSO/R_MATPAL    |0165          |         |/VSO/M_MATNR_PAL        |MARA            |C        |000036|
|KNA1       |/VSO/R_I_NO_LYR  |0166          |         |/VSO/M_IPAL_NO_LYR      |                |N        |000004|
|KNA1       |/VSO/R_ONE_MAT   |0167          |         |/VSO/M_ONE_MAT          |                |C        |000002|
|KNA1       |/VSO/R_ONE_SORT  |0168          |         |/VSO/M_ONE_SORT         |                |C        |000002|
|KNA1       |/VSO/R_ULD_SIDE  |0169          |         |/VSO/M_UNLOAD_SIDE_PREF |                |N        |000002|
|KNA1       |/VSO/R_LOAD_PREF |0170          |         |/VSO/M_LOAD_PREF        |                |N        |000002|
|KNA1       |/VSO/R_DPOINT    |0171          |         |/VSO/R_DELIVERYPOINT    |/VSO/R_DPOINT   |C        |000020|
|KNA1       |.INCLU--AP       |0172          |         |                        |                |         |000000|
|KNA1       |ALC              |0173          |         |FMFG_ALC                |FMFGT_ALC       |C        |000016|
|KNA1       |PMT_OFFICE       |0174          |         |FMFG_PMT_OFF            |FMFGT_PO        |C        |000010|
|KNA1       |.INCLUDE         |0175          |         |                        |                |         |000000|
|KNA1       |FEE_SCHEDULE     |0176          |         |FM_FEE_SCHED            |                |C        |000008|
|KNA1       |DUNS             |0177          |         |FMCCRDUNS               |                |C        |000018|
|KNA1       |DUNS4            |0178          |         |FMCCRDUNS4              |                |C        |000008|
|KNA1       |SAM_UE_ID        |0179          |         |FMFG_UNIQUE_ENTITY_ID   |                |C        |000024|
|KNA1       |SAM_EFT_IND      |0180          |         |FMFG_EFT_IND            |                |C        |000008|
|KNA1       |.INCLU--AP       |0181          |         |                        |                |         |000000|
|KNA1       |PSOFG            |0182          |         |PSOFG                   |PSO19           |C        |000020|
|KNA1       |PSOIS            |0183          |         |PSOIS                   |                |C        |000040|
|KNA1       |.INCLUDE         |0184          |         |                        |                |         |000000|
|KNA1       |PSON1            |0185          |         |NAME1_GP                |                |C        |000070|
|KNA1       |PSON2            |0186          |         |NAME2_GP                |                |C        |000070|
|KNA1       |PSON3            |0187          |         |NAME3_GP                |                |C        |000070|
|KNA1       |PSOVN            |0188          |         |PSOVN                   |                |C        |000070|
|KNA1       |PSOTL            |0189          |         |PSOTL                   |                |C        |000040|
|KNA1       |PSOHS            |0190          |         |PSOHS                   |                |C        |000012|
|KNA1       |PSOST            |0191          |         |PSOST                   |                |C        |000056|
|KNA1       |.INCLUDE         |0192          |         |                        |                |         |000000|
|KNA1       |PSOO1            |0193          |         |PSOO1                   |                |C        |000100|
|KNA1       |PSOO2            |0194          |         |PSOO1                   |                |C        |000100|
|KNA1       |PSOO3            |0195          |         |PSOO1                   |                |C        |000100|
|KNA1       |PSOO4            |0196          |         |PSOO1                   |                |C        |000100|
|KNA1       |PSOO5            |0197          |         |PSOO1                   |                |C        |000100|
-------------------------------------------------------------------------------------------------------------------

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.

Best regards
Stefan

IT RUN!!!

thank you!!! you’ve made me very happy!!!

Now with this method my automation will be faster!

thanks a lot

Loris

1 Like

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?

@l.sambinelli

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’

1 Like

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

  1. 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
image
the add data row contain customer code
image

The code give me error

RFC_READ_TABLE: A condition specified dynamically has an unexpected format.

and the variable uipath pass to sap is
image

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.

image

And I tried your full example and it works perfect too.

{"ERDAT = '" & datetime.now.AddYears(-2).ToString(“yyyyMMdd”) & "' AND KTOKK = 'ITLO' AND LOEVM = 'X'"}

image

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

{"OEVM EQ SPACE"}
1 Like

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