Application Development Blog Posts
Learn and share on deeper, cross technology development topics such as integration and connectivity, automation, cloud extensibility, developing at scale, and security.
cancel
Showing results for 
Search instead for 
Did you mean: 
viral_bhuva
Explorer
  • Usually we face problems while using BAPIs for extension. Either extensions are not properly filled or they are filled with some special characters (garbage values).
  • Even if the extension structures for BAPI are properly adjusted I have faced this issue.

Consider BAPI BAPI_SALESORDER_CHANGE:

  • Let work area for extension(ls_vbap) have following type.

TYPES: BEGIN OF ty_vbap,
vbeln            TYPE vbap-vbeln,
posnr            TYPE vbap-posnr,
zzzlang          TYPE vbap-zzzlang,
zzzdruck         TYPE vbap-zzzdruck

And so on …

  • The extension table (t_extension_in) be of type bapiparex.

  • BAPI accepts the extension table in character format, so we generally change it like :

CLEAR t_extension_in.
t_extension_in-structure     = 'BAPE_VBAP'.


MOVE ls_vbap to t_extension_in+30 .
t_extension_in-valuepart1    = ls_vbap(240).
t_extension_in-valuepart2    = ls_vbap+240.
APPEND t_extension_in.

  • This BAPI internally changes the extension table to hexadecimal and then it converts it to character format. So sometimes the original values are wrongly interpreted. So we get garbage values (for eg: ### ) in the customer fields.

  • Now if we change the original type of ls_vbap first to hexadecimal and then convert these to character format and then append it to extension table then the internal conversion in BAPI will not give garbage values.

  FIELD-SYMBOLS: <fs_x_vbap>     TYPE x,
<fs_c_vbap>     TYPE c.

  CLEAR t_extension_in.
t_extension_in-structure     = 'BAPE_VBAP'.

* Converting into Hexadecimal value.
ASSIGN ls_vbap        TO <fs_x_vbap>     CASTING.

* Converting Hexadecimal to  char.
ASSIGN <fs_x_vbap> TO <fs_c_vbap>     CASTING.

* Filling Extension table ( excluding first field of 30 char)
t_extension_in+30 = <fs_c_vbap>.

APPEND t_extension_in.

  • After these conversion the values in customer fields will appear correctly.

1 Comment