Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
3,634

Introduction:


One of the most important package while developing automations with SAP Applications(Create Sale orders, Create Purchase orders, Posting Invoice Documents) is by using the BAPI SDK, which saves the developers time and life easy by providing the

  1. Inbuilt validations

  2. spending time to understand business logic

  3. No screen recording is required

  4. Bot will run in background with no UI interaction.

  5. Compare to Desktop studio ,in cloud studio BAPI SDK activities available readily with out much coding effort like create, close connection, Execute BAPI, output parameters available with out declaration in JSON format.


What is BAPI:

BAPIs are stored as RFC (Remote Function Call) capable function modules in the ABAP (Advanced Business Application Programming) Workbench Function Builder. BAPIs have standard business interfaces that enable external applications (with the help of SAP business objects) to access SAP processes, functions, and data.

Prerequisites:

  • desktop agent version is equal to or greater than 2.0.16.

  • Configure SAP connection (SSO or Basic) on your system.

  • Ensure you have added BAPI SDK Package in SAP IRPA Cloud studio in dependency section.


Requirement:


Read the Purchase order header ,Item  and  history details using BAPI:BAPI_PO_GETDETAIL1 and download to JSON file.

Working with BAPI SDK:

  • Identify the input and output parameters of BAPI using SE37 transaction in SAP.(PURCHASEORDER,POHEADER,POITEM,POHISTORY)



  1. Make a note of Input Parameters.

  2. Make a note of output parameters to read from BAPI



  • Create datatype import in Cloud Studio with the same parameters names(case-sensitive) as in BAPI

  • pass the input parameters for  Set SAP Connection (Basic) activity like user, password, message server, system ID , instance Number and client.

  • create import variable using the  import data type which created in  above step.

  • pass the BAPI name, import variable to Execute BAPI activity

  • Make a note of output variable(step3.BAPIResponse) of Execute BAPI step using this will retrieve the PO header item and history details.

  • get  PO history, header and item details.

  • Stringify and beautify the json data before download for readability.
    return JSON.stringify(poitem, null, 4);
    return JSON.stringify(poheader, null, 4);
    return JSON.stringify(pohistory, null, 4);​


  • Important point to make a note here is all output parameters of BAPI are available in JSON format with out declaring it in cloud studio. access output parameters like step3.BAPIResponse.<outputparameter_of_BAPI)

  • optionally filter the output response by providing the comma separated output parameter names  in output field.

  • Download the response to JSON file

  • Close the SAP Connection.

  • Now our automation is ready for execution

  • After executing automation will get response in Header data JSON format
    {
    "PO_NUMBER": "1000420289",
    "COMP_CODE": "8342",
    "DOC_TYPE": "NB",
    "DELETE_IND": "",
    "STATUS": "9",
    "CREAT_DATE": "20211102",
    "CREATED_BY": "TEST",
    "ITEM_INTVL": "00010",
    "VENDOR": "0000002110",
    "LANGU": "E",
    "LANGU_ISO": "EN",
    "PMNTTRMS": "0000",
    "DSCNT1_TO": "0",
    "DSCNT2_TO": "0",
    "DSCNT3_TO": "0",
    "DSCT_PCT1": "0.000",
    "DSCT_PCT2": "0.000",
    "PURCH_ORG": "2120",
    "PUR_GROUP": "002",
    "CURRENCY": "INR",
    "CURRENCY_ISO": "INR",
    "EXCH_RATE": "1.00000",
    "EX_RATE_FX": "",
    "DOC_DATE": "20211102",
    "VPER_START": "00000000",
    "VPER_END": "00000000",
    "WARRANTY": "00000000",
    "QUOTATION": "",
    "QUOT_DATE": "00000000",
    "REF_1": "",
    "SALES_PERS": "",
    "TELEPHONE": "",
    "SUPPL_VEND": "",
    "CUSTOMER": "",
    "AGREEMENT": "",
    "GR_MESSAGE": "",
    "SUPPL_PLNT": "",
    "INCOTERMS1": "",
    "INCOTERMS2": "",
    "COLLECT_NO": "",
    "DIFF_INV": "",
    "OUR_REF": "",
    "LOGSYSTEM": "",
    "SUBITEMINT": "00001",
    "PO_REL_IND": "1",
    "REL_STATUS": "XX",
    "VAT_CNTRY": "INR",
    "VAT_CNTRY_ISO": "INR",
    "REASON_CANCEL": "00",
    "REASON_CODE": "",
    "RETENTION_TYPE": "",
    "RETENTION_PERCENTAGE": "0.00",
    "DOWNPAY_TYPE": "",
    "DOWNPAY_AMOUNT": "0.0000",
    "DOWNPAY_PERCENT": "0.00",
    "DOWNPAY_DUEDATE": "00000000",
    "MEMORY": "",
    "MEMORYTYPE": "",
    "SHIPTYPE": "",
    "HANDOVERLOC": "",
    "SHIPCOND": "",
    "INCOTERMSV": "",
    "INCOTERMS2L": "",
    "INCOTERMS3L": "",
    "EXT_SYS": "",
    "EXT_REF": "",
    "INTRASTAT_REL": "",
    "INTRASTAT_EXCL": ""
    }​


  • Item data
    [
    {
    "PO_ITEM": "00010",
    "DELETE_IND": "",
    "SHORT_TEXT": "TEST material",
    "MATERIAL": "MATERIAL1",
    "MATERIAL_EXTERNAL": "",
    "MATERIAL_GUID": "",
    "MATERIAL_VERSION": "",
    "EMATERIAL": "MATERIAL",
    "EMATERIAL_EXTERNAL": "",
    "EMATERIAL_GUID": "",
    "EMATERIAL_VERSION": "",
    "PLANT": "2120",
    "STGE_LOC": "0060",
    "TRACKINGNO": "",
    "MATL_GROUP": "0884",
    "INFO_REC": "5300339387",
    "VEND_MAT": "",
    "QUANTITY": "20.000",
    "PO_UNIT": "EA",
    "PO_UNIT_ISO": "EA",
    "ORDERPR_UN": "EA",
    "ORDERPR_UN_ISO": "PR",
    "CONV_NUM1": "12",
    "CONV_DEN1": "1",
    "NET_PRICE": "10.000000000",
    "PRICE_UNIT": "1",
    "GR_PR_TIME": "30",
    "TAX_CODE": "",
    "BON_GRP1": "",
    "QUAL_INSP": "X",
    "INFO_UPD": "C",
    "PRNT_PRICE": "",
    "EST_PRICE": "",
    "REMINDER1": "0",
    "REMINDER2": "0",
    "REMINDER3": "0",
    "OVER_DLV_TOL": "0.0",
    "UNLIMITED_DLV": "",
    "UNDER_DLV_TOL": "0.0",
    "VAL_TYPE": "",
    "NO_MORE_GR": "X",
    "FINAL_INV": "",
    "ITEM_CAT": "0",
    "ACCTASSCAT": "",
    "DISTRIB": "",
    "PART_INV": "",
    "GR_IND": "X",
    "GR_NON_VAL": "",
    "IR_IND": "X",
    "FREE_ITEM": "",
    "GR_BASEDIV": "X",
    "ACKN_REQD": "",
    "ACKNOWL_NO": "",
    "AGREEMENT": "",
    "AGMT_ITEM": "00000",
    "SHIPPING": "",
    "CUSTOMER": "",
    "COND_GROUP": "",
    "NO_DISCT": "",
    "PLAN_DEL": "45",
    "NET_WEIGHT": "23.400",
    "WEIGHTUNIT": "KG",
    "WEIGHTUNIT_ISO": "KGM",
    "TAXJURCODE": "",
    "CTRL_KEY": "",
    "CONF_CTRL": "",
    "REV_LEV": "",
    "FUND": "",
    "FUNDS_CTR": "",
    "CMMT_ITEM": "",
    "PRICEDATE": "",
    "PRICE_DATE": "20211102",
    "GROSS_WT": "23.400",
    "VOLUME": "0.000",
    "VOLUMEUNIT": "",
    "VOLUMEUNIT_ISO": "",
    "INCOTERMS1": "",
    "INCOTERMS2": "",
    "PRE_VENDOR": "",
    "VEND_PART": "",
    "HL_ITEM": "00000",
    "GR_TO_DATE": "00000000",
    "SUPP_VENDOR": "",
    "SC_VENDOR": "",
    "KANBAN_IND": "",
    "ERS": "",
    "R_PROMO": "",
    "POINTS": "0.000",
    "POINT_UNIT": "",
    "POINT_UNIT_ISO": "",
    "SEASON": "",
    "SEASON_YR": "",
    "BON_GRP2": "",
    "BON_GRP3": "",
    "SETT_ITEM": "",
    "MINREMLIFE": "0",
    "RFQ_NO": "",
    "RFQ_ITEM": "00000",
    "PREQ_NO": "1015820674",
    "PREQ_ITEM": "00010",
    "REF_DOC": "",
    "REF_ITEM": "00000",
    "SI_CAT": "",
    "RET_ITEM": "",
    "AT_RELEV": "",
    "ORDER_REASON": "",
    "BRAS_NBM": "",
    "MATL_USAGE": "",
    "MAT_ORIGIN": "",
    "IN_HOUSE": "",
    "INDUS3": "",
    "INF_INDEX": "",
    "UNTIL_DATE": "00000000",
    "DELIV_COMPL": "",
    "PART_DELIV": "",
    "SHIP_BLOCKED": "",
    "PREQ_NAME": "",
    "PERIOD_IND_EXPIRATION_DATE": "",
    "INT_OBJ_NO": "000000000000000000",
    "PCKG_NO": "0000000000",
    "BATCH": "",
    "VENDRBATCH": "",
    "CALCTYPE": "",
    "GRANT_NBR": "",
    "CMMT_ITEM_LONG": "",
    "FUNC_AREA_LONG": "",
    "NO_ROUNDING": "",
    "PO_PRICE": "",
    "SUPPL_STLOC": "",
    "SRV_BASED_IV": "",
    "FUNDS_RES": "",
    "RES_ITEM": "000",
    "ORIG_ACCEPT": "",
    "ALLOC_TBL": "",
    "ALLOC_TBL_ITEM": "00000",
    "SRC_STOCK_TYPE": "",
    "REASON_REJ": "",
    "CRM_SALES_ORDER_NO": "",
    "CRM_SALES_ORDER_ITEM_NO": "000000",
    "CRM_REF_SALES_ORDER_NO": "",
    "CRM_REF_SO_ITEM_NO": "",
    "PRIO_URGENCY": "00",
    "PRIO_REQUIREMENT": "255",
    "REASON_CODE": "",
    "FUND_LONG": "",
    "LONG_ITEM_NUMBER": "",
    "EXTERNAL_SORT_NUMBER": "00000",
    "EXTERNAL_HIERARCHY_TYPE": "",
    "RETENTION_PERCENTAGE": "0.00",
    "DOWNPAY_TYPE": "",
    "DOWNPAY_AMOUNT": "0.0000",
    "DOWNPAY_PERCENT": "0.00",
    "DOWNPAY_DUEDATE": "00000000",
    "EXT_RFX_NUMBER": "",
    "EXT_RFX_ITEM": "",
    "EXT_RFX_SYSTEM": "",
    "SRM_CONTRACT_ID": "",
    "SRM_CONTRACT_ITM": "0000000000",
    "BUDGET_PERIOD": "",
    "BLOCK_REASON_ID": "",
    "BLOCK_REASON_TEXT": "",
    "SPE_CRM_FKREL": "",
    "DATE_QTY_FIXED": "",
    "GI_BASED_GR": "",
    "SHIPTYPE": "",
    "HANDOVERLOC": "",
    "TC_AUT_DET": "",
    "MANUAL_TC_REASON": "",
    "FISCAL_INCENTIVE": "",
    "FISCAL_INCENTIVE_ID": "",
    "TAX_SUBJECT_ST": "",
    "REQ_SEGMENT": "",
    "STK_SEGMENT": "",
    "SF_TXJCD": "",
    "INCOTERMS2L": "",
    "INCOTERMS3L": "",
    "MATERIAL_LONG": "MATERIAL1",
    "EMATERIAL_LONG": "MATERIAL1",
    "SERVICEPERFORMER": "",
    "PRODUCTTYPE": "1",
    "STARTDATE": "00000000",
    "ENDDATE": "00000000",
    "REQ_SEG_LONG": "",
    "STK_SEG_LONG": "",
    "EXPECTED_VALUE": "0.000000000",
    "LIMIT_AMOUNT": "0.000000000",
    "EXT_REF": "",
    "GL_ACCOUNT": "",
    "COSTCENTER": "",
    "WBS_ELEMENT": "",
    "COMMODITY_CODE": "",
    "INTRASTAT_SERVICE_CODE": ""
    }
    ]​


  • History data
    [
    {
    "PO_ITEM": "00010",
    "SERIAL_NO": "00",
    "PROCESS_ID": "1",
    "DOC_YEAR": "2021",
    "MAT_DOC": "5017845820",
    "MATDOC_ITM": "0001",
    "HIST_TYPE": "E",
    "MOVE_TYPE": "101",
    "PSTNG_DATE": "20211102",
    "QUANTITY": "20.000",
    "VAL_LOCCUR": "200.0000",
    "VAL_FORCUR": "200.0000",
    "CURRENCY": "INR",
    "CL_VAL_LOC": "0.0000",
    "BLOCKED_QY": "0.000",
    "BL_QTY": "0.000",
    "DB_CR_IND": "S",
    "VAL_TYPE": "",
    "NO_MORE_GR": "X",
    "REF_DOC_NO": "",
    "REF_DOC_YR": "2021",
    "REF_DOC": "5017845820",
    "REF_DOC_IT": "0001",
    "MOVE_REAS": "0000",
    "ENTRY_DATE": "20211102",
    "ENTRY_TIME": "153519",
    "IVVAL_LOC": "0.0000",
    "IVVAL_FOR": "0.0000",
    "MATERIAL": "MATERIAL1",
    "PLANT": "2345",
    "CONF_SER": "0000",
    "CONDITION": "",
    "TAX_CODE": "",
    "DELIV_QTY": "0.000",
    "DELIV_UNIT": "",
    "PUR_MAT": "",
    "LOC_CURR": "INR",
    "BATCH": "0006730306",
    "DOC_DATE": "20211102",
    "CURRENCY_ISO": "INR",
    "LOC_CURR_ISO": "INR",
    "DELIV_UNIT_ISO": "",
    "MATERIAL_EXTERNAL": "",
    "MATERIAL_GUID": "",
    "MATERIAL_VERSION": "",
    "PUR_MAT_EXTERNAL": "",
    "PUR_MAT_GUID": "",
    "PUR_MAT_VERSION": "",
    "REF_DOC_NO_LONG": "",
    "STK_SEGMENT": "",
    "MATERIAL_LONG": "MATERIAL1",
    "PUR_MAT_LONG": "",
    "STK_SEG_LONG": ""
    },
    {
    "PO_ITEM": "00010",
    "SERIAL_NO": "00",
    "PROCESS_ID": "1",
    "DOC_YEAR": "2021",
    "MAT_DOC": "5017845821",
    "MATDOC_ITM": "0001",
    "HIST_TYPE": "E",
    "MOVE_TYPE": "102",
    "PSTNG_DATE": "20211102",
    "QUANTITY": "20.000",
    "VAL_LOCCUR": "200.0000",
    "VAL_FORCUR": "200.0000",
    "CURRENCY": "INR",
    "CL_VAL_LOC": "0.0000",
    "BLOCKED_QY": "0.000",
    "BL_QTY": "0.000",
    "DB_CR_IND": "H",
    "VAL_TYPE": "",
    "NO_MORE_GR": "",
    "REF_DOC_NO": "",
    "REF_DOC_YR": "2021",
    "REF_DOC": "5017845820",
    "REF_DOC_IT": "0001",
    "MOVE_REAS": "0000",
    "ENTRY_DATE": "20211102",
    "ENTRY_TIME": "170252",
    "IVVAL_LOC": "0.0000",
    "IVVAL_FOR": "0.0000",
    "MATERIAL": "MATERIAL1",
    "PLANT": "2345",
    "CONF_SER": "0000",
    "CONDITION": "",
    "TAX_CODE": "",
    "DELIV_QTY": "0.000",
    "DELIV_UNIT": "",
    "PUR_MAT": "",
    "LOC_CURR": "INR",
    "BATCH": "0006730306",
    "DOC_DATE": "20211102",
    "CURRENCY_ISO": "INR",
    "LOC_CURR_ISO": "INR",
    "DELIV_UNIT_ISO": "",
    "MATERIAL_EXTERNAL": "",
    "MATERIAL_GUID": "",
    "MATERIAL_VERSION": "",
    "PUR_MAT_EXTERNAL": "",
    "PUR_MAT_GUID": "",
    "PUR_MAT_VERSION": "",
    "REF_DOC_NO_LONG": "",
    "STK_SEGMENT": "",
    "MATERIAL_LONG": "MATERIAL1",
    "PUR_MAT_LONG": "",
    "STK_SEG_LONG": ""
    },
    {
    "PO_ITEM": "00010",
    "SERIAL_NO": "00",
    "PROCESS_ID": "1",
    "DOC_YEAR": "2021",
    "MAT_DOC": "5017845822",
    "MATDOC_ITM": "0001",
    "HIST_TYPE": "E",
    "MOVE_TYPE": "101",
    "PSTNG_DATE": "20211102",
    "QUANTITY": "20.000",
    "VAL_LOCCUR": "2400.0000",
    "VAL_FORCUR": "2400.0000",
    "CURRENCY": "INR",
    "CL_VAL_LOC": "0.0000",
    "BLOCKED_QY": "0.000",
    "BL_QTY": "0.000",
    "DB_CR_IND": "S",
    "VAL_TYPE": "",
    "NO_MORE_GR": "X",
    "REF_DOC_NO": "",
    "REF_DOC_YR": "2021",
    "REF_DOC": "5017845822",
    "REF_DOC_IT": "0001",
    "MOVE_REAS": "0000",
    "ENTRY_DATE": "20211102",
    "ENTRY_TIME": "171620",
    "IVVAL_LOC": "0.0000",
    "IVVAL_FOR": "0.0000",
    "MATERIAL": "MATERIAL1",
    "PLANT": "2120",
    "CONF_SER": "0000",
    "CONDITION": "",
    "TAX_CODE": "",
    "DELIV_QTY": "0.000",
    "DELIV_UNIT": "",
    "PUR_MAT": "",
    "LOC_CURR": "INR",
    "BATCH": "0006730307",
    "DOC_DATE": "20211102",
    "CURRENCY_ISO": "INR",
    "LOC_CURR_ISO": "INR",
    "DELIV_UNIT_ISO": "",
    "MATERIAL_EXTERNAL": "",
    "MATERIAL_GUID": "",
    "MATERIAL_VERSION": "",
    "PUR_MAT_EXTERNAL": "",
    "PUR_MAT_GUID": "",
    "PUR_MAT_VERSION": "",
    "REF_DOC_NO_LONG": "",
    "STK_SEGMENT": "",
    "MATERIAL_LONG": "MATERIAL1",
    "PUR_MAT_LONG": "",
    "STK_SEG_LONG": ""
    }
    ]​



 

Conclusion:

It saves time for spending on orchestration logic compare to desktop studio and we can also encapsulate existing business logic in custom RFC as per customer needs. I hope it helps you to how to use the BAPI SDK in SAP IRPA cloud studio.

 

Thanks for reading and please provide your comments and questions.

 

For More Information :SAP HELP

Please follow me here:

9_sandeepmohan

 
Labels in this area