Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Write for a whole structure?

Former Member
0 Likes
3,465

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.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,422

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.

2 REPLIES 2
Read only

Former Member
0 Likes
1,422

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

Read only

Former Member
0 Likes
1,423

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