Calling an SAP BAPI via RFC

The function module BAPI_MATERIAL_GET_DETAIL is used to retrieve information about a material.


GuiXT
// sample material number
Set V[matnr] "100"

// Structure to read material data via BAPI
CreateStructure "V[matdata]"  _ 
    matl_desc matl_group base_uom gross_wt net_weight unit_of_wt

//read data from SAP
Call "BAPI_MATERIAL_GET_DETAIL" _
  export.MATERIAL="matnr" _ 
  import.MATERIAL_GENERAL_DATA="matdata"

// display basic material data
InputField (1,1) "Material" _	 
           (1,20) size=40 name="matnr" -readOnly
InputField (2,1) "Description" _
           (2,20) size=40 name="matdata.matl_desc" -readOnly
InputField (3,1) "Material Group"  _
           (3,20) size=40 name="matdata.matl_group" -readOnly
InputField (4,1) "Base Unit of Measure" _ 
           (4,20) size=40 name="matdata.base_uom"  -readOnly
InputField (6,1) "Gross weight" _ 
           (6,20) size=40 name="matdata.gross_wt" -readOnly
InputField (7,1) "Net Weight"  _
           (7,20) size=40 name="matdata.net_weight" -readOnly
InputField (8,1) "Net Weight"  _
           (8,20) size=40 name="matdata.unit_of_wt" -readOnly
Reading the SAP database

The function module /guixt/dbselect (from GuiXT Utilities) is used to read the SAP database.


GuiXT
CreateTable V[customers] kunnr name1 name2 ort01 country

Set V[table] "KNA1"
Set V[condition] "kunnr like 'K%' "
Set V[fields] "kunnr,name1,name2,ort01,land1"

// select data from table KNA1
Call /guixt/dbselect _
  export.table="table" _
  export.condition="condition" _
  export.fields="fields" _
  import.values="customers"

//display result
Table	(1,1)	(20,120)	title="Customers"	name="customers"	 
Column "Account" size=10 name="kunnr"
Column "Name1"  size=30 name="name1"
Column "Name2"  size=30 name="name2"
Column "City"   size=16 name="ort01"
Column "Country code"   size=16 name="ort01"