2015 Apr 01 12:11 PM
Hi, is there a command in ABAP which allows me to print a whole structure with just one line of code?
I mean s.th. like var_dump(...) in php.
2015 Apr 01 12:45 PM
Use case ?
If it is debug as usual var_dump in php is used then there's a way to do that...
If it is asigning then there's a lot of ways to achive similiar things. (you can just MOVE, but only first 255 cahrs are moved if I'm right)
For now example can besomething like (using sy system structure)
DATA : dk_string_example type string.
CALL FUNCTION 'SO_STRUCT_TO_CHAR'
EXPORTING ip_struct = sy
IMPORTING EP_STRING = dk_string_example
write dk_string_example.
Take a look in that function how it works so maybe you can do it without function.
Depends what and why you need it.
Hope this helps
Hi, is there a command in ABAP which allows me to print a whole structure with just one line of code?
I mean s.th. like var_dump(...) in php.
2015 Apr 01 12:43 PM
Hi Michael,
No, no this kind of command. But you can do it like this.
DATA: wa_mara TYPE mara.
wa_mara-matnr = '1234567'.
wa_mara-ersda = '20150607'.
START-OF-SELECTION.
PERFORM f_write_str USING wa_mara.
*&---------------------------------------------------------------------*
*& Form f_write_str Put this FORM into a include program, then you can reuse it.
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_STR text
* -->FIELD-SYMBOLS text
* --><FS> text
*----------------------------------------------------------------------*
FORM f_write_str USING p_str TYPE any.
FIELD-SYMBOLS <fs> TYPE ANY.
DO 5 TIMES.
ASSIGN COMPONENT sy-index OF STRUCTURE p_str TO <fs>.
IF <fs> IS ASSIGNED.
WRITE: <fs>.
ELSE.
EXIT.
ENDIF.
ENDDO.
ENDFORM. "f_write_str
regards,
Archer
2015 Apr 01 12:45 PM
Use case ?
If it is debug as usual var_dump in php is used then there's a way to do that...
If it is asigning then there's a lot of ways to achive similiar things. (you can just MOVE, but only first 255 cahrs are moved if I'm right)
For now example can besomething like (using sy system structure)
DATA : dk_string_example type string.
CALL FUNCTION 'SO_STRUCT_TO_CHAR'
EXPORTING ip_struct = sy
IMPORTING EP_STRING = dk_string_example
write dk_string_example.
Take a look in that function how it works so maybe you can do it without function.
Depends what and why you need it.
Hope this helps
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |