Create PureBasic structure from any SAP table
Posted: Fri Jun 03, 2011 11:29 am
Hello community,
here is a small ABAP program to create a PureBasic structure from any SAP table you want.
Cheers
Stefan
Here is the table USR01:
Here is the result from the table USR01:
here is a small ABAP program to create a PureBasic structure from any SAP table you want.
Cheers
Stefan
Code: Select all
"-Begin-----------------------------------------------------------------
Report zCreatePureBasStrucFromTable.
"-Main--------------------------------------------------------------
Perform CreateStruc Using 'USR01'.
"-Sub CreateStruc---------------------------------------------------
Form CreateStruc Using TableName Type String.
"-Structures----------------------------------------------------
Types: Begin Of TableStruc,
TabName Type DD03L-TABNAME,
FieldName Type DD03L-FIELDNAME,
Position Type DD03L-POSITION,
IntType Type DD03L-INTTYPE,
IntLen Type DD03L-INTLEN,
End Of TableStruc.
"-Variables-----------------------------------------------------
Data ResultTable Type Table Of TableStruc.
Field-Symbols <ResultTable> Type TableStruc.
Data FieldName Type String.
Data iIntLen Type Integer.
Data strIntLen Type String.
"-Get structure data from DD03L table---------------------------
Select * From DD03L Into Corresponding Fields Of Table
ResultTable Where TABNAME = TableName Order By Position.
"-Write structure data------------------------------------------
Write: / ` ; Structure from Table ` No-Gap.
Write: TableName No-Gap.
Write: / ` Structure str` No-Gap.
Write: TableName.
Loop At ResultTable Assigning <ResultTable>.
Write: / ` ` No-Gap.
FieldName = <ResultTable>-FieldName.
Condense FieldName.
Write: FieldName No-Gap.
Case <ResultTable>-IntType.
"-Signed 4-Byte integer-----------------------------------
When 'I'.
Write: `.l`.
"-Floating point 8-Byte-----------------------------------
When 'F'.
Write: `.d`.
"-Each other as fixed string------------------------------
When Others.
Write: `.s{` No-Gap.
iIntLen = <ResultTable>-IntLen.
strIntLen = iIntLen.
Condense strIntLen.
Write: strIntLen No-Gap.
Write: `}`.
EndCase.
EndLoop.
Write: / ` EndStructure`.
Write: /.
EndForm.
"-End-------------------------------------------------------------------
Code: Select all
MANDT CLNT 3
BNAME CHAR 12
STCOD CHAR 20
SPLD CHAR 4
SPLG CHAR 1
SPDB CHAR 1
SPDA CHAR 1
DATFM CHAR 1
DCPFM CHAR 1
HDEST CHAR 8
HMAND CLNT 3
HNAME CHAR 12
MENON CHAR 1
MENUE CHAR 20
STRTT CHAR 20
LANGU LANG 1
CATTKENNZ CHAR 1
TIMEFM CHAR 1
Code: Select all
; Structure from Table USR01
Structure strUSR01
MANDT.s{3}
BNAME.s{12}
STCOD.s{20}
SPLD.s{4}
SPLG.s{1}
SPDB.s{1}
SPDA.s{1}
DATFM.s{1}
DCPFM.s{1}
HDEST.s{8}
HMAND.s{3}
HNAME.s{12}
MENON.s{1}
MENUE.s{20}
STRTT.s{20}
LANGU.s{1}
CATTKENNZ.s{1}
TIMEFM.s{1}
EndStructure