Value operator is a relatively new addition to the ABAP language and the developers already have started extensively using this feature. But here I am writing about one of its functionality which is not widely noticed .
More about value operator from ABAP documentation,
Code from CL_API_RESERVATION_DOC_DPC_EXT - Local Test Class
We no more have to declare the input structures for a FM/BAPI separately . We could use the value statement with the corresponding structure and feed with the values for the parameters. This feature is useful particularly when used in test classes. The icing on the cake is, we could even assign a functional method to the parameter list. Easy huh ??
Footnote: But one strange thing which I noticed is that , we can only feed structures with a value to the function modules/BAPI's but not internal tables. I wonder why. May be the list gets longer? But could have been good enough for testing classes with one or two line items?
materialdescription = value t_bapi_makt( ( langu = 'D'
langu_iso = 'DE'
matl_desc = 'Sample Material'
del_flag = ' ' ) )
returnmessages = value cfx_bi_tt_bapi_matreturn2( ( type = 'E'
ID = 'SD'
number = '120'
message = 'Sample' ) ).
The above code throws error when used with BAPI 'BAPI_MATERIAL_SAVEDATA' .