Author Topic: Use call command to get native SAP function module detail  (Read 8079 times)

Leo Chu

  • GuiXT Forum
  • Newbie
  • *
  • Posts: 16
    • View Profile
Use call command to get native SAP function module detail
« on: August 01, 2017, 02:40:50 PM »
Liquid UI: Use call to get native SAP function module detail

This example is to use call command to get the detail from native SAP function module.
ex:   SAP_WAPI_COUNT_WORKITEMS
         BAPI_MATERIAL_GET_ALL
         ALM_ME_FUNCLOC_INSTALLED_EQUI
         BAPI_ALM_ORDER_GET_DETAIL
         BAPI_USER_GET_DETAIL
         BAPISDORDER_GETDETAILEDLIST
   
By using the command with extra structure object, it is able to get different type of data from FM.

Note: valid from WS version 1.2.326.0 or Server version 3.5.563.0 and above



Step 1: Prerequisite

The function module needs to be remote callable, or Liquid UI will not be able to execute it through RFC.



Step 2: Confirm ouput structure according to parameter

The structure of each output parameter needs to be specified individually.
Its detail can be referenced from SAP in transaction SE37 follow by below steps.
1.   On initial screen of SE37, enter the FM
2.   Click on "Display" button to check detail
3.   On the display screen, select "Export" or "Tables" tab according to your output
4.   In corresponding tab, find the row of output parameter and double click on it to see detail structure



Step 3: Define the type object of ouput structure

For each output parameter in the function module, we need to specify individual structure object.
See Convert function module structure detail into type object to generate ready-to-use type object for selected structure.

Use FM BAPI_ALM_ORDER_GET_DETAIL as an example, its ES_HEADER parameter has structure BAPI_ALM_ORDER_HEADER_E as below.

Quote
   var z_BAPI_ALM_ORDER_HEADER_E = {
      name:'BAPI_ALM_ORDER_HEADER_E',
      components:[
         { name:'ORDERID',    length:12,    decimalpl:0,  type:'C' },                               //Order Number
         { name:'ORDER_TYPE',    length:4,    decimalpl:0,  type:'C' },                               //Order Type
         { name:'PLANPLANT',    length:4,    decimalpl:0,  type:'C' },                               //Maintenance Planning Plant
         { name:'BUS_AREA',    length:4,    decimalpl:0,  type:'C' },                               //Business Area
         { name:'MN_WK_CTR',    length:8,    decimalpl:0,  type:'C' },                               //Main work center for maintenance tasks
         { name:'PLANT',    length:4,    decimalpl:0,  type:'C' },                               //Plant associated with main work center
         { name:'MN_WKCTR_ID',    length:8,    decimalpl:0,  type:'N' },    /** NUMC **/      //Object ID of the Work Center
         { name:'PMACTTYPE',    length:3,    decimalpl:0,  type:'C' },                               //Maintenance activity type
         { name:'PLANGROUP',    length:3,    decimalpl:0,  type:'C' },                               //Planner Group for Customer Service and Plant Maintenance
         { name:'SYSTCOND',    length:1,    decimalpl:0,  type:'C' },                               //Syst.Condition
         { name:'FUNCT_LOC',    length:30,    decimalpl:0,  type:'C' },                               //Functional Location
         { name:'EQUIPMENT',    length:18,    decimalpl:0,  type:'C' },                               //Equipment Number
         { name:'SERIALNO',    length:18,    decimalpl:0,  type:'C' },                               //Serial Number
         { name:'MATERIAL',    length:18,    decimalpl:0,  type:'C' },                               //Material Number
         { name:'ASSEMBLY',    length:18,    decimalpl:0,  type:'C' },                               //Assembly
         { name:'DEVICEDATA',    length:40,    decimalpl:0,  type:'C' },                               //Additional Device Data
         { name:'MAINTPLANT',    length:4,    decimalpl:0,  type:'C' },                               //Maintenance plant
         { name:'LOCATION',    length:10,    decimalpl:0,  type:'C' },                               //Asset location
         { name:'MAINTROOM',    length:8,    decimalpl:0,  type:'C' },                               //Room
         { name:'PLSECTN',    length:3,    decimalpl:0,  type:'C' },                               //Plant section
         { name:'LOC_WK_CTR',    length:8,    decimalpl:0,  type:'C' },                               //Work center
         { name:'LOC_WKCTR_ID',    length:8,    decimalpl:0,  type:'N' },    /** NUMC **/      //Object ID of PP work center
         { name:'ABCINDIC',    length:1,    decimalpl:0,  type:'C' },                               //ABC indicator for technical object
         { name:'SORTFIELD',    length:30,    decimalpl:0,  type:'C' },                               //Sort field
         { name:'COMP_CODE',    length:4,    decimalpl:0,  type:'C' },                               //Company Code
         { name:'PROFIT_CTR',    length:10,    decimalpl:0,  type:'C' },                               //Profit Center
         { name:'CO_AREA',    length:4,    decimalpl:0,  type:'C' },                               //Controlling Area
         { name:'RESPCCTR',    length:10,    decimalpl:0,  type:'C' },                               //Responsible cost center
         { name:'FUNC_AREA',    length:16,    decimalpl:0,  type:'C' },                               //Functional Area
         { name:'SUPERIOR_NETWORK',    length:12,    decimalpl:0,  type:'C' },                               //Number of superior network
         { name:'SUPERIOR_ACTIVITY',    length:4,    decimalpl:0,  type:'C' },                               //Activity number in network and standard network
         { name:'SUPERIOR_ROUTING_NO',    length:10,    decimalpl:0,  type:'N' },    /** NUMC **/      //Routing number of operations in the order
         { name:'SUPERIOR_COUNTER',    length:8,    decimalpl:0,  type:'N' },    /** NUMC **/      //General counter for order
         { name:'WBS_ELEM',    length:8,    decimalpl:0,  type:'N' },    /** NUMC **/      //Work Breakdown Structure Element (WBS Element)
         { name:'PROJ_DEF',    length:8,    decimalpl:0,  type:'N' },    /** NUMC **/      //Project definition
         { name:'PROCESSING_GROUP',    length:2,    decimalpl:0,  type:'N' },    /** NUMC **/      //Processing group
         { name:'OBJECTCLASS',    length:2,    decimalpl:0,  type:'C' },                               //Object Class
         { name:'TAXJURCODE',    length:15,    decimalpl:0,  type:'C' },                               //Tax Jurisdiction
         { name:'LOC_COMP_CODE',    length:4,    decimalpl:0,  type:'C' },                               //Company Code
         { name:'LOC_CO_AREA',    length:4,    decimalpl:0,  type:'C' },                               //Controlling Area
         { name:'ASSET_NO',    length:12,    decimalpl:0,  type:'C' },                               //Main Asset Number
         { name:'SUB_NUMBER',    length:4,    decimalpl:0,  type:'C' },                               //Asset Subnumber
         { name:'LOC_BUS_AREA',    length:4,    decimalpl:0,  type:'C' },                               //Business Area
         { name:'COSTCENTER',    length:10,    decimalpl:0,  type:'C' },                               //Cost Center
         { name:'LOC_WBS_ELEM',    length:8,    decimalpl:0,  type:'N' },    /** NUMC **/      //Work Breakdown Structure Element (WBS Element)
         { name:'STANDORDER',    length:12,    decimalpl:0,  type:'C' },                               //Standing order number
         { name:'SETTLORDER',    length:12,    decimalpl:0,  type:'C' },                               //Settlement order
         { name:'SALESORG',    length:4,    decimalpl:0,  type:'C' },                               //Sales Organization
         { name:'DISTR_CHAN',    length:2,    decimalpl:0,  type:'C' },                               //Distribution Channel
         { name:'DIVISION',    length:2,    decimalpl:0,  type:'C' },                               //Division
         { name:'ORDPLANID',    length:1,    decimalpl:0,  type:'C' },                               //Maintenance order planning indicator
         { name:'START_DATE',    length:8,    decimalpl:0,  type:'D' },    /** DATS **/      //Basic start date
         { name:'FINISH_DATE',    length:8,    decimalpl:0,  type:'D' },    /** DATS **/      //Basic finish date
         { name:'BASICSTART',    length:6,    decimalpl:0,  type:'T' },    /** TIMS **/      //Basic start time
         { name:'BASIC_FIN',    length:6,    decimalpl:0,  type:'T' },    /** TIMS **/      //Basic finish (time)
         { name:'PRIORITY',    length:1,    decimalpl:0,  type:'C' },                               //Priority
         { name:'REVISION',    length:8,    decimalpl:0,  type:'C' },                               //Revision for Plant Maintenance and Customer Service
         { name:'VERSION',    length:2,    decimalpl:0,  type:'N' },    /** NUMC **/      //Version of Available Capacity
         { name:'SCHED_TYPE',    length:1,    decimalpl:0,  type:'C' },                               //Scheduling type
         { name:'AUTOSCHED',    length:1,    decimalpl:0,  type:'C' },                               //Indicator: Schedule automatically
         { name:'CAP_REQMTS',    length:1,    decimalpl:0,  type:'C' },                               //Indicator: Calculate capacity requirements
         { name:'SCHEDULING_EXACT_BREAK_TIMES',    length:1,    decimalpl:0,  type:'C' },                               //Indicator:  Scheduling allowing for breaks
         { name:'MRP_RELEVANT',    length:1,    decimalpl:0,  type:'C' },                               //Reservation Relevance/Generation of Purchase Requisition
         { name:'PRODUCTION_START_DATE',    length:8,    decimalpl:0,  type:'D' },    /** DATS **/      //Scheduled start
         { name:'PRODUCTION_FINISH_DATE',    length:8,    decimalpl:0,  type:'D' },    /** DATS **/      //Scheduled finish
         { name:'PRODUCTION_START_TIME',    length:6,    decimalpl:0,  type:'T' },    /** TIMS **/      //Scheduled Start (Time)
         { name:'PRODUCTION_FINISH_TIME',    length:6,    decimalpl:0,  type:'T' },    /** TIMS **/      //Scheduled finish time
         { name:'ACTUAL_START_DATE',    length:8,    decimalpl:0,  type:'D' },    /** DATS **/      //Actual start date
         { name:'ACTUAL_FINISH_DATE',    length:8,    decimalpl:0,  type:'D' },    /** DATS **/      //Confirmed Order Finish Date
         { name:'ACTUAL_START_TIME',    length:6,    decimalpl:0,  type:'T' },    /** TIMS **/      //Actual start time
         { name:'ACTUAL_FINISH_TIME',    length:6,    decimalpl:0,  type:'T' },    /** TIMS **/      //Confirmed order finish (time)
         { name:'REFDATE',    length:8,    decimalpl:0,  type:'D' },    /** DATS **/      //PM Order: Reference Date
         { name:'SALES_ORD',    length:10,    decimalpl:0,  type:'C' },                               //Sales Order Number
         { name:'S_ORD_ITEM',    length:6,    decimalpl:0,  type:'N' },    /** NUMC **/      //Item Number in Sales Order
         { name:'CALC_MOTIVE',    length:2,    decimalpl:0,  type:'C' },                               //Accounting Indicator
         { name:'INVEST_PROFILE',    length:6,    decimalpl:0,  type:'C' },                               //Investment measure profile
         { name:'SCALE',    length:2,    decimalpl:0,  type:'C' },                               //Scale of investment objects
         { name:'INV_REASON',    length:2,    decimalpl:0,  type:'C' },                               //Reason for investment
         { name:'ENVIR_INVEST',    length:5,    decimalpl:0,  type:'C' },                               //Reason for environmental investment
         { name:'ESTIMATED_COSTS',    length:11,    decimalpl:2,  type:'P' },    /** CURR **/      //Estimated total costs of order
         { name:'CURRENCY',    length:5,    decimalpl:0,  type:'C' },    /** CUKY **/      //Order Currency
         { name:'CURRENCY_ISO',    length:3,    decimalpl:0,  type:'C' },                               //ISO currency code
         { name:'CSTG_SHEET',    length:6,    decimalpl:0,  type:'C' },                               //Costing Sheet
         { name:'OVERHEAD_KEY',    length:6,    decimalpl:0,  type:'C' },                               //Overhead key
         { name:'RES_ANAL_KEY',    length:6,    decimalpl:0,  type:'C' },                               //Results Analysis Key
         { name:'NETWORK_PROFILE',    length:7,    decimalpl:0,  type:'C' },                               //Network profile
         { name:'CSTGVAPPLN',    length:4,    decimalpl:0,  type:'C' },                               //Costing variant for planned costs
         { name:'CSTGVARACT',    length:4,    decimalpl:0,  type:'C' },                               //Costing variant for actual costs
         { name:'TASK_LIST_GROUP',    length:8,    decimalpl:0,  type:'C' },                               //Key for Task List Group
         { name:'GROUP_COUNTER',    length:2,    decimalpl:0,  type:'C' },                               //Group Counter
         { name:'TASK_LIST_TYPE',    length:1,    decimalpl:0,  type:'C' },                               //Task List Type
         { name:'RESP_PLANNER_GROUP',    length:3,    decimalpl:0,  type:'C' },                               //Responsible planner group/department
         { name:'MNTPLAN',    length:12,    decimalpl:0,  type:'C' },                               //Maintenance Plan
         { name:'MAINTITEM',    length:16,    decimalpl:0,  type:'C' },                               //Maintenance item
         { name:'CALL_NO',    length:10,    decimalpl:0,  type:'I' },    /** INT4 **/      //Maintenance Plan Call Number
         { name:'LAST_ORD',    length:12,    decimalpl:0,  type:'C' },                               //Order number
         { name:'ENTERED_BY',    length:12,    decimalpl:0,  type:'C' },                               //Entered by
         { name:'ENTER_DATE',    length:8,    decimalpl:0,  type:'D' },    /** DATS **/      //Created on
         { name:'CHANGED_BY',    length:12,    decimalpl:0,  type:'C' },                               //Last changed by
         { name:'CHANGE_DATE',    length:8,    decimalpl:0,  type:'D' },    /** DATS **/      //Change date for Order Master
         { name:'SCENARIO',    length:4,    decimalpl:0,  type:'C' },                               //Scenario or Subscreen Category
         { name:'SYS_STATUS',    length:40,    decimalpl:0,  type:'C' },                               //System Status
         { name:'USER_ST',    length:1,    decimalpl:0,  type:'C' },                               //User status active
         { name:'USERSTATUS',    length:40,    decimalpl:0,  type:'C' },                               //Field displaying user status
         { name:'STAT_PROF',    length:8,    decimalpl:0,  type:'C' },                               //Status Profile
         { name:'OBJECT_NO',    length:22,    decimalpl:0,  type:'C' },                               //Object number
         { name:'ROUTING_NO',    length:10,    decimalpl:0,  type:'N' },    /** NUMC **/      //Routing number of operations in the order
         { name:'RESERV_NO',    length:10,    decimalpl:0,  type:'N' },    /** NUMC **/      //Number of Reservation/Dependent Requirement
         { name:'SHORT_TEXT',    length:40,    decimalpl:0,  type:'C' },                               //Description
         { name:'LONG_TEXT',    length:1,    decimalpl:0,  type:'C' },                               //Long text exists
         { name:'NOTIF_NO',    length:12,    decimalpl:0,  type:'C' },                               //Notification No
         { name:'ASSEMBLY_EXTERNAL',    length:40,    decimalpl:0,  type:'C' },                               //Long Material Number for Field ASSEMBLY
         { name:'ASSEMBLY_GUID',    length:32,    decimalpl:0,  type:'C' },                               //External GUID for ASSEMBLY Field
         { name:'ASSEMBLY_VERSION',    length:10,    decimalpl:0,  type:'C' },                               //Version Number for ASSEMBLY Field
         { name:'MATERIAL_EXTERNAL',    length:40,    decimalpl:0,  type:'C' },                               //Long Material Number for MATERIAL Field
         { name:'MATERIAL_GUID',    length:32,    decimalpl:0,  type:'C' },                               //External GUID for MATERIAL Field
         { name:'MATERIAL_VERSION',    length:10,    decimalpl:0,  type:'C' },                               //Version Number for MATERIAL Field
         { name:'CALID',    length:2,    decimalpl:0,  type:'C' },                               //Factory Calendar
         { name:'KALSN',    length:2,    decimalpl:0,  type:'N' },    /** NUMC **/      //Calendar Selection for Order
         { name:'SUPERIOR_ORDERID',    length:12,    decimalpl:0,  type:'C' },                               //Number of superior order
         { name:'LEADING_ORDERID',    length:12,    decimalpl:0,  type:'C' },                               //Leading order in current processing
         { name:'START_POINT',    length:18,    decimalpl:0,  type:'C' },                               //Start Point
         { name:'END_POINT',    length:18,    decimalpl:0,  type:'C' },                               //End Point
         { name:'LINEAR_LENGTH',    length:18,    decimalpl:0,  type:'C' },                               //Length
         { name:'LINEAR_UNIT',    length:3,    decimalpl:0,  type:'C' },    /** UNIT **/      //Unit of Measurement for Linear Data
         { name:'LINEAR_UNIT_ISO',    length:3,    decimalpl:0,  type:'C' },                               //Unit of Measurement for Linear Data in ISO Code
         { name:'FIRST_OFFSET_TYPE_CODE',    length:2,    decimalpl:0,  type:'C' },                               //Type of First Offset
         { name:'FIRST_OFFSET_VALUE',    length:18,    decimalpl:0,  type:'C' },                               //Value of Offset 1
         { name:'FIRST_OFFSET_UNIT',    length:3,    decimalpl:0,  type:'C' },    /** UNIT **/      //Unit of Measurement for Offset 1
         { name:'FIRST_OFFSET_UNIT_ISO',    length:3,    decimalpl:0,  type:'C' },                               //Unit of Measurement for Offset 1 in ISO Code
         { name:'SECOND_OFFSET_TYPE_CODE',    length:2,    decimalpl:0,  type:'C' },                               //Type of Second Offset
         { name:'SECOND_OFFSET_VALUE',    length:18,    decimalpl:0,  type:'C' },                               //Value of Offset 2
         { name:'SECOND_OFFSET_UNIT',    length:3,    decimalpl:0,  type:'C' },    /** UNIT **/      //Unit of Measurement for Offset 2
         { name:'SECOND_OFFSET_UNIT_ISO',    length:3,    decimalpl:0,  type:'C' },                               //Unit of Measurement for Offset 2 in ISO Code
         { name:'FIRST_OFFSET_TYPE_CODE_NAME',    length:60,    decimalpl:0,  type:'C' },                               //First Offset Type Description
         { name:'SECOND_OFFSET_TYPE_CODE_NAME',    length:60,    decimalpl:0,  type:'C' },                               //Second Offset Type Description
         { name:'MARKER_START_POINT',    length:18,    decimalpl:0,  type:'C' },                               //Marker for Start Point
         { name:'MARKER_DISTANCE_START_POINT',    length:18,    decimalpl:0,  type:'C' },                               //Distance between Marker and Start Point
         { name:'MARKER_END_POINT',    length:18,    decimalpl:0,  type:'C' },                               //Marker for End Point
         { name:'MARKER_DISTANCE_END_POINT',    length:18,    decimalpl:0,  type:'C' },                               //Length Spec for Distance between Marker and End Point
         { name:'MARKER_DISTANCE_UNIT',    length:3,    decimalpl:0,  type:'C' },    /** UNIT **/      //Unit for the Distance from Marker
         { name:'MARKER_DISTANCE_UNIT_ISO',    length:3,    decimalpl:0,  type:'C' },                               //Unit for the Distance from Marker in ISO Code
         { name:'PRIOTYPE',    length:2,    decimalpl:0,  type:'C' }                               //Priority Type
      ]
   };

It's able to include more than one output parameter in the same call command, which you need to specify the other structure object as well.
Here we have a table parameter ET_OPERATIONS has structure BAPI_ALM_ORDER_OPERATION_E as below.

Quote
   var z_BAPI_ALM_ORDER_OPERATION_E = {
      name:'BAPI_ALM_ORDER_OPERATION_E',
      components:[
         { name:'ACTIVITY',    length:4,    decimalpl:0,  type:'C' },                               //Operation/Activity Number
         { name:'SUB_ACTIVITY',    length:4,    decimalpl:0,  type:'C' },                               //Suboperation
         { name:'CONTROL_KEY',    length:4,    decimalpl:0,  type:'C' },                               //Control key
         { name:'WORK_CNTR',    length:8,    decimalpl:0,  type:'C' },                               //Work center
         { name:'PLANT',    length:4,    decimalpl:0,  type:'C' },                               //Plant
         { name:'STANDARD_TEXT_KEY',    length:7,    decimalpl:0,  type:'C' },                               //Standard text key
         { name:'DESCRIPTION',    length:40,    decimalpl:0,  type:'C' },                               //Operation short text
         { name:'LANGU',    length:1,    decimalpl:0,  type:'C' },    /** LANG **/      //Language Key
         { name:'LANGU_ISO',    length:2,    decimalpl:0,  type:'C' },                               //2-Character SAP Language Code
         { name:'NO_OF_TIME_TICKETS',    length:3,    decimalpl:0,  type:'P' },    /** DEC **/      //Number of Time Tickets
         { name:'WAGETYPE',    length:4,    decimalpl:0,  type:'C' },                               //Wage Type
         { name:'SUITABILITY',    length:2,    decimalpl:0,  type:'C' },                               //Suitability
         { name:'WAGEGROUP',    length:3,    decimalpl:0,  type:'C' },                               //Wage group
         { name:'SORT_FLD',    length:10,    decimalpl:0,  type:'C' },                               //Sort field
         { name:'VENDOR_NO',    length:10,    decimalpl:0,  type:'C' },                               //Account Number of Vendor or Creditor
         { name:'QUANTITY',    length:13,    decimalpl:3,  type:'P' },    /** QUAN **/      //Operation quantity in order unit of measure
         { name:'BASE_UOM',    length:3,    decimalpl:0,  type:'C' },    /** UNIT **/      //Base Unit of Measure
         { name:'BASE_UOM_ISO',    length:3,    decimalpl:0,  type:'C' },                               //ISO code for unit of measurement
         { name:'PRICE',    length:11,    decimalpl:2,  type:'P' },    /** CURR **/      //Price
         { name:'PRICE_UNIT',    length:5,    decimalpl:0,  type:'P' },    /** DEC **/      //Price Unit
         { name:'COST_ELEMENT',    length:10,    decimalpl:0,  type:'C' },                               //Cost Element
         { name:'CURRENCY',    length:5,    decimalpl:0,  type:'C' },    /** CUKY **/      //Currency Key
         { name:'CURRENCY_ISO',    length:3,    decimalpl:0,  type:'C' },                               //ISO currency code
         { name:'INFO_REC',    length:10,    decimalpl:0,  type:'C' },                               //Number of Purchasing Info Record
         { name:'PURCH_ORG',    length:4,    decimalpl:0,  type:'C' },                               //Purchasing Organization
         { name:'PUR_GROUP',    length:3,    decimalpl:0,  type:'C' },                               //Purchasing group for external processing
         { name:'MATL_GROUP',    length:9,    decimalpl:0,  type:'C' },                               //Material Group
         { name:'AGREEMENT',    length:10,    decimalpl:0,  type:'C' },                               //Number of Principal Purchase Agreement
         { name:'AGMT_ITEM',    length:5,    decimalpl:0,  type:'N' },    /** NUMC **/      //Item Number of Principal Purchase Agreement
         { name:'PREQ_NAME',    length:12,    decimalpl:0,  type:'C' },                               //Name of Requisitioner/Requester
         { name:'TRACKINGNO',    length:10,    decimalpl:0,  type:'C' },                               //Requirement Tracking Number
         { name:'NUMBER_OF_CAPACITIES',    length:3,    decimalpl:0,  type:'b' },    /** INT1 **/      //Number of capacities required
         { name:'PERCENT_OF_WORK',    length:3,    decimalpl:0,  type:'b' },    /** INT1 **/      //Work percentage
         { name:'CALC_KEY',    length:1,    decimalpl:0,  type:'C' },                               //Key for calculation
         { name:'ACTTYPE',    length:6,    decimalpl:0,  type:'C' },                               //Activity Type
         { name:'SYSTCOND',    length:1,    decimalpl:0,  type:'C' },                               //Syst.Condition
         { name:'ASSEMBLY',    length:18,    decimalpl:0,  type:'C' },                               //Assembly
         { name:'INT_DISTR',    length:8,    decimalpl:0,  type:'C' },                               //Distr.cap.reqmts (plant maint.,process order, network)
         { name:'GR_RCPT',    length:12,    decimalpl:0,  type:'C' },                               //Goods Recipient/Ship-To Party
         { name:'UNLOAD_PT',    length:25,    decimalpl:0,  type:'C' },                               //Unloading Point
         { name:'PERS_NO',    length:8,    decimalpl:0,  type:'N' },    /** NUMC **/      //Personnel number
         { name:'FW_ORDER',    length:10,    decimalpl:0,  type:'C' },                               //Framework Order
         { name:'ORDER_ITEM',    length:5,    decimalpl:0,  type:'N' },    /** NUMC **/      //Item of framework order
         { name:'PLND_DELRY',    length:3,    decimalpl:0,  type:'P' },    /** DEC **/      //Planned Delivery Time in Days
         { name:'DURATION_NORMAL',    length:5,    decimalpl:1,  type:'P' },    /** QUAN **/      //Normal duration of the activity
         { name:'DURATION_NORMAL_UNIT',    length:3,    decimalpl:0,  type:'C' },    /** UNIT **/      //Normal duration/unit
         { name:'DURATION_NORMAL_UNIT_ISO',    length:3,    decimalpl:0,  type:'C' },                               //ISO code for unit of measurement
         { name:'CONSTRAINT_TYPE_START',    length:1,    decimalpl:0,  type:'C' },                               //Constraint on the basic start date for the activity
         { name:'CONSTRAINT_TYPE_FINISH',    length:1,    decimalpl:0,  type:'C' },                               //Constraint on the finish date of the activity
         { name:'WORK_ACTIVITY',    length:7,    decimalpl:1,  type:'P' },    /** QUAN **/      //Work involved in the activity
         { name:'UN_WORK',    length:3,    decimalpl:0,  type:'C' },    /** UNIT **/      //Unit for work
         { name:'UN_WORK_ISO',    length:3,    decimalpl:0,  type:'C' },                               //ISO code for unit of measurement
         { name:'START_CONS',    length:8,    decimalpl:0,  type:'D' },    /** DATS **/      //Constraint for activity start (Basic)
         { name:'STRTTIMCON',    length:6,    decimalpl:0,  type:'T' },    /** TIMS **/      //Constraint for activity start time (Basic)
         { name:'FIN_CONSTR',    length:8,    decimalpl:0,  type:'D' },    /** DATS **/      //Constraint for finish of activity (Basic)
         { name:'FINTIMCONS',    length:6,    decimalpl:0,  type:'T' },    /** TIMS **/      //Basic finish time of the activity
         { name:'EXECFACTOR',    length:3,    decimalpl:0,  type:'P' },    /** DEC **/      //Execution Factor
         { name:'MRP_RELEVANT',    length:1,    decimalpl:0,  type:'C' },                               //Reservation Relevance/Generation of Purchase Requisition
         { name:'FIELD_KEY',    length:7,    decimalpl:0,  type:'C' },                               //Key word ID for user-defined fields
         { name:'USR00',    length:20,    decimalpl:0,  type:'C' },                               //User field with 20 characters
         { name:'USR01',    length:20,    decimalpl:0,  type:'C' },                               //User field with 20 characters
         { name:'USR02',    length:10,    decimalpl:0,  type:'C' },                               //User field with 10 characters
         { name:'USR03',    length:10,    decimalpl:0,  type:'C' },                               //User field with 10 characters
         { name:'USR04',    length:13,    decimalpl:3,  type:'P' },    /** QUAN **/      //User field for quantity (length 10.3)
         { name:'USE04',    length:3,    decimalpl:0,  type:'C' },    /** UNIT **/      //User field: Unit for quantity fields
         { name:'USE04_ISO',    length:3,    decimalpl:0,  type:'C' },                               //ISO code for unit of measurement
         { name:'USR05',    length:13,    decimalpl:3,  type:'P' },    /** QUAN **/      //User field for quantity (length 10.3)
         { name:'USE05',    length:3,    decimalpl:0,  type:'C' },    /** UNIT **/      //User field: Unit for quantity fields
         { name:'USE05_ISO',    length:3,    decimalpl:0,  type:'C' },                               //ISO code for unit of measurement
         { name:'USR06',    length:13,    decimalpl:3,  type:'P' },    /** CURR **/      //User-defined field for values (length 10,3)
         { name:'USE06',    length:5,    decimalpl:0,  type:'C' },    /** CUKY **/      //User field: Unit for value fields
         { name:'USE06_ISO',    length:3,    decimalpl:0,  type:'C' },                               //ISO currency code
         { name:'USR07',    length:13,    decimalpl:3,  type:'P' },    /** CURR **/      //User-defined field for values (length 10,3)
         { name:'USE07',    length:5,    decimalpl:0,  type:'C' },    /** CUKY **/      //User field: Unit for value fields
         { name:'USE07_ISO',    length:3,    decimalpl:0,  type:'C' },                               //ISO currency code
         { name:'USR08',    length:8,    decimalpl:0,  type:'D' },    /** DATS **/      //User field for date
         { name:'USR09',    length:8,    decimalpl:0,  type:'D' },    /** DATS **/      //User field for date
         { name:'USR10',    length:1,    decimalpl:0,  type:'C' },                               //User-defined field: Indicator for reports
         { name:'USR11',    length:1,    decimalpl:0,  type:'C' },                               //User-defined field: Indicator for reports
         { name:'CONF_NO',    length:10,    decimalpl:0,  type:'N' },    /** NUMC **/      //Completion confirmation number for the operation
         { name:'PREQ_NO',    length:10,    decimalpl:0,  type:'C' },                               //Purchase requisition number
         { name:'PREQ_ITEM',    length:5,    decimalpl:0,  type:'N' },    /** NUMC **/      //Item number of the purchase requisition in the order
         { name:'COMPLETE',    length:1,    decimalpl:0,  type:'C' },                               //Indicator: No Remaining Work Expected
         { name:'WORK_ACTUAL',    length:13,    decimalpl:3,  type:'P' },    /** QUAN **/      //Actual work
         { name:'EARL_SCHED_START_DATE',    length:8,    decimalpl:0,  type:'D' },    /** DATS **/      //Earliest scheduled start: Execution (date)
         { name:'EARL_SCHED_START_TIME',    length:6,    decimalpl:0,  type:'T' },    /** TIMS **/      //Earliest scheduled start: Execution (time)
         { name:'EARL_SCHED_FIN_DATE',    length:8,    decimalpl:0,  type:'D' },    /** DATS **/      //Earliest scheduled finish: Execution (date)
         { name:'EARL_SCHED_FIN_TIME',    length:6,    decimalpl:0,  type:'T' },    /** TIMS **/      //Earliest scheduled finish: Execution (time)
         { name:'LATE_SCHED_START_DATE',    length:8,    decimalpl:0,  type:'D' },    /** DATS **/      //Latest scheduled start: Execution (date)
         { name:'LATE_SCHED_START_TIME',    length:6,    decimalpl:0,  type:'T' },    /** TIMS **/      //Latest scheduled start: Execution (time)
         { name:'LATE_SCHED_FIN_DATE',    length:8,    decimalpl:0,  type:'D' },    /** DATS **/      //Latest scheduled finish: Execution (date)
         { name:'LATE_SCHED_FIN_TIME',    length:6,    decimalpl:0,  type:'T' },    /** TIMS **/      //Latest scheduled finish: Execution (time)
         { name:'ACT_START_DATE',    length:8,    decimalpl:0,  type:'D' },    /** DATS **/      //Actual start: Execution (date)
         { name:'ACT_START_TIME',    length:6,    decimalpl:0,  type:'T' },    /** TIMS **/      //Actual start: Execution/setup (time)
         { name:'ACT_END_DATE',    length:8,    decimalpl:0,  type:'D' },    /** DATS **/      //Actual finish: Execution (date)
         { name:'ACT_END_TIME',    length:6,    decimalpl:0,  type:'T' },    /** TIMS **/      //Actual finish: Execution (time)
         { name:'FCST_FIN_DATE',    length:8,    decimalpl:0,  type:'D' },    /** DATS **/      //Forecast finish date of operation from confirmation
         { name:'FCST_FIN_TIME',    length:6,    decimalpl:0,  type:'T' },    /** TIMS **/      //Forecast finish time of operation from confirmation
         { name:'FREE_BUFFER',    length:3,    decimalpl:0,  type:'P' },    /** DEC **/      //Free float
         { name:'TOTAL_BUFFER',    length:3,    decimalpl:0,  type:'P' },    /** DEC **/      //Total float
         { name:'WORK_FORECAST',    length:7,    decimalpl:1,  type:'P' },    /** QUAN **/      //Forecasted work (actual + remaining)
         { name:'SYSTEM_STATUS_TEXT',    length:40,    decimalpl:0,  type:'C' },                               //System Status
         { name:'ASSEMBLY_EXTERNAL',    length:40,    decimalpl:0,  type:'C' },                               //Long Material Number for Field ASSEMBLY
         { name:'ASSEMBLY_GUID',    length:32,    decimalpl:0,  type:'C' },                               //External GUID for ASSEMBLY Field
         { name:'ASSEMBLY_VERSION',    length:10,    decimalpl:0,  type:'C' },                               //Version Number for ASSEMBLY Field
         { name:'EQUIPMENT',    length:18,    decimalpl:0,  type:'C' },                               //Equipment Number
         { name:'FUNCT_LOC',    length:30,    decimalpl:0,  type:'C' },                               //Functional Location
         { name:'NOTIF_NO',    length:12,    decimalpl:0,  type:'C' },                               //Notification No
         { name:'START_POINT',    length:18,    decimalpl:0,  type:'C' },                               //Start Point
         { name:'END_POINT',    length:18,    decimalpl:0,  type:'C' },                               //End Point
         { name:'LINEAR_LENGTH',    length:18,    decimalpl:0,  type:'C' },                               //Length
         { name:'LINEAR_UNIT',    length:3,    decimalpl:0,  type:'C' },    /** UNIT **/      //Unit of Measurement for Linear Data
         { name:'LINEAR_UNIT_ISO',    length:3,    decimalpl:0,  type:'C' },                               //Unit of Measurement for Linear Data in ISO Code
         { name:'FIRST_OFFSET_TYPE_CODE',    length:2,    decimalpl:0,  type:'C' },                               //Type of First Offset
         { name:'FIRST_OFFSET_VALUE',    length:18,    decimalpl:0,  type:'C' },                               //Value of Offset 1
         { name:'FIRST_OFFSET_UNIT',    length:3,    decimalpl:0,  type:'C' },    /** UNIT **/      //Unit of Measurement for Offset 1
         { name:'FIRST_OFFSET_UNIT_ISO',    length:3,    decimalpl:0,  type:'C' },                               //Unit of Measurement for Offset 1 in ISO Code
         { name:'SECOND_OFFSET_TYPE_CODE',    length:2,    decimalpl:0,  type:'C' },                               //Type of Second Offset
         { name:'SECOND_OFFSET_VALUE',    length:18,    decimalpl:0,  type:'C' },                               //Value of Offset 2
         { name:'SECOND_OFFSET_UNIT',    length:3,    decimalpl:0,  type:'C' },    /** UNIT **/      //Unit of Measurement for Offset 2
         { name:'SECOND_OFFSET_UNIT_ISO',    length:3,    decimalpl:0,  type:'C' },                               //Unit of Measurement for Offset 2 in ISO Code
         { name:'FIRST_OFFSET_TYPE_CODE_NAME',    length:60,    decimalpl:0,  type:'C' },                               //First Offset Type Description
         { name:'SECOND_OFFSET_TYPE_CODE_NAME',    length:60,    decimalpl:0,  type:'C' },                               //Second Offset Type Description
         { name:'MARKER_START_POINT',    length:18,    decimalpl:0,  type:'C' },                               //Marker for Start Point
         { name:'MARKER_DISTANCE_START_POINT',    length:18,    decimalpl:0,  type:'C' },                               //Distance between Marker and Start Point
         { name:'MARKER_END_POINT',    length:18,    decimalpl:0,  type:'C' },                               //Marker for End Point
         { name:'MARKER_DISTANCE_END_POINT',    length:18,    decimalpl:0,  type:'C' },                               //Length Spec for Distance between Marker and End Point
         { name:'MARKER_DISTANCE_UNIT',    length:3,    decimalpl:0,  type:'C' },    /** UNIT **/      //Unit for the Distance from Marker
         { name:'MARKER_DISTANCE_UNIT_ISO',    length:3,    decimalpl:0,  type:'C' },                               //Unit for the Distance from Marker in ISO Code
         { name:'PCKG_NO',    length:10,    decimalpl:0,  type:'N' },    /** NUMC **/      //Package number
         { name:'COMP_CODE',    length:4,    decimalpl:0,  type:'C' },                               //Company Code
         { name:'MAINTENANCE_ACTIVITY_TYPE',    length:3,    decimalpl:0,  type:'C' },                               //Maintenance activity type
         { name:'BUS_AREA',    length:4,    decimalpl:0,  type:'C' },                               //Business Area
         { name:'WBS_ELEM',    length:8,    decimalpl:0,  type:'N' },    /** NUMC **/      //Work breakdown structure element (WBS element)
         { name:'PROFIT_CTR',    length:10,    decimalpl:0,  type:'C' },                               //Profit Center
         { name:'CSTG_SHEET',    length:6,    decimalpl:0,  type:'C' },                               //Costing Sheet
         { name:'OVERHEAD_KEY',    length:6,    decimalpl:0,  type:'C' },                               //Overhead key
         { name:'TAXJURCODE',    length:15,    decimalpl:0,  type:'C' },                               //Tax Jurisdiction
         { name:'OBJECTCLASS',    length:2,    decimalpl:0,  type:'C' },                               //Object Class
         { name:'FUNC_AREA',    length:16,    decimalpl:0,  type:'C' },                               //Functional Area
         { name:'OFFSET_START',    length:5,    decimalpl:0,  type:'P' },    /** QUAN **/      //Offset to sub-operation start
         { name:'OFFSET_START_UNIT',    length:3,    decimalpl:0,  type:'C' },    /** UNIT **/      //Unit for offset to start
         { name:'OFFSET_START_UNIT_ISO',    length:3,    decimalpl:0,  type:'C' },                               //ISO code for unit of measurement
         { name:'OFFSET_END',    length:5,    decimalpl:0,  type:'P' },    /** QUAN **/      //Offset to sub-operation finish
         { name:'OFFSET_END_UNIT',    length:3,    decimalpl:0,  type:'C' },    /** UNIT **/      //Unit for offset to finish
         { name:'OFFSET_END_UNIT_ISO',    length:3,    decimalpl:0,  type:'C' }                               //ISO code for unit of measurement
      ]
   };   



Step 4: Specify the call command

Compare to regular call command, specify structure type object with output parameter.

Quote
   rfcResult = call("BAPI_ALM_ORDER_GET_DETAIL", {"in.NUMBER":"000000815289",
                                    "out.ES_HEADER(type:z_BAPI_ALM_ORDER_HEADER_E)":"z_bapi_order_header",
                                    "table.ET_OPERATIONS(width:3000,type:z_BAPI_ALM_ORDER_OPERATION_E)":"z_bapi_order_operations"});
   println("=====>> BAPI_ALM_ORDER_GET_DETAIL Exception:"+rfcResult.exception+"<==");
Note:   "rfcResult.exception" will carry any exception for RFC if happen

Note:   Notice the two output paramters have different type objects specified.

Note:   More detail of how to use call command please see
call()



Step 5: Read result data

If output is export parameter with specified type(out.ES_HEADER(type:z_BAPI_ALM_ORDER_HEADER_E)), the result variable is an object.
If output is table parameter with specified type(table.ET_OPERATIONS(width:3000,type:z_BAPI_ALM_ORDER_OPERATION_E)), the result variable is an object array.

Use below logic to print out values from object or object array in Cornelius window.

Quote
   for (var idx in z_bapi_order_header){
      println("=====>>" + idx + "\t==>"+ z_bapi_order_header[idx]+"<==");
   }

   println("\n\n\n========================================================\n\n\n");
   
   for (var j in z_bapi_order_operations){
      for (var k in z_bapi_order_operations[j]){
         println("=====>>" + j + "-" + k + "\t==>" + z_bapi_order_operations[j][k]+"<==");
      }
   }

To get specific value from object:
   z_bapi_order_header.ORDERID      //Order Number
   z_bapi_order_header.ORDER_TYPE      //Order Type
   
To get specific value from object array:
   z_bapi_order_operations[0].ACTIVITY      //Operation/Activity Number
   z_bapi_order_operations[0].CONTROL_KEY      //Control key



Step 6: Use function to wrap the logic

Since the type object construct logic will only be required when we try to execute the call command, it is more efficient to put entire logic into a function.
Whenever we need this logic in the script of function, we can directly execute the function to get returned result.
Quote
function callBAPI_ALM_ORDER_GET_DETAIL(){
   var z_BAPI_ALM_ORDER_HEADER_E = {
      ......
   };

   var z_BAPI_ALM_ORDER_OPERATION_E = {
      ......
   };
   
   rfcResult = call("BAPI_ALM_ORDER_GET_DETAIL", {"in.NUMBER":"000000815289",
                                    "out.ES_HEADER(type:z_BAPI_ALM_ORDER_HEADER_E)":"z_bapi_order_header",
                                    "table.ET_OPERATIONS(width:3000,type:z_BAPI_ALM_ORDER_OPERATION_E)":"z_bapi_order_operations"});
   println("=====>> BAPI_ALM_ORDER_GET_DETAIL Exception:"+rfcResult.exception+"<==");

   for (var idx in z_bapi_order_header){
      println("=====>>" + idx + "\t==>"+ z_bapi_order_header[idx]+"<==");
   }

   println("\n\n\n========================================================\n\n\n");
   
   for (var j in z_bapi_order_operations){
      for (var k in z_bapi_order_operations[j]){
         println("=====>>" + j + "-" + k + "\t==>" + z_bapi_order_operations[j][k]+"<==");
      }
   }
}


Step 7: Create a button to trigger the function

pushbutton([8,0], "BAPI_ALM_ORDER_GET_DETAIL", "?", {"process":callBAPI_ALM_ORDER_GET_DETAIL, "size":[1,30]});




See attachments for full script example
« Last Edit: May 09, 2019, 02:44:06 PM by Rahul Gera »