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

select query

Former Member
0 Likes
764

when i am using SELECT* FROM MARA INTO TABLE IT_MARA. in WRITE we mention each field name (IT_MARA-MATNR) that need to be printed. i want to know how to print whole selected data in output without mentioning each field in write statement , is there any query like that.

plz help me.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
731

Hi,

I think there is no possibility to avoid mentioning each field name, if you use write statement.

If you use ALV or grid output using FM, you have to mention each and every field in field catalog.

So its better to use this class to display all the fields and values of a particular table.

Try the following code snippet. You 'll get an idea.

REPORT ztest.

DATA: l_alv TYPE REF TO cl_gui_alv_grid,

lt_mara TYPE TABLE OF mara.

SELECT * FROM mara INTO TABLE lt_mara.

  • Creation of the ALV object, when we use cl_gui_container=>screen0 as parent, the ALVGrid control will

  • automatically use the full screen to display the grid, NO CONTAINER DEFINITION IS REQUIRED !

CREATE OBJECT l_alv

EXPORTING i_parent = cl_gui_container=>screen0.

  • calling the display of the grid, the system will automatically create the fieldcatalog based

  • on the table name you pass in parameter

CALL METHOD l_alv->set_table_for_first_display

EXPORTING i_structure_name = 'MARA'

CHANGING it_outtab = lt_mara.

  • You have to create an EMPTY screen, put NOTHING in the layout and this is going to workCALL SCREEN 100

*Instead of creating an empty screen 100, you can also define an empty selection screen in you program and use it, no more screen painter required !

SELECTION-SCREEN BEGIN OF SCREEN 1001.

SELECTION-SCREEN END OF SCREEN 1001.

CALL SELECTION-SCREEN 1001.

Regards,

Arun Prasath Kumar.

4 REPLIES 4
Read only

Former Member
0 Likes
732

Hi,

I think there is no possibility to avoid mentioning each field name, if you use write statement.

If you use ALV or grid output using FM, you have to mention each and every field in field catalog.

So its better to use this class to display all the fields and values of a particular table.

Try the following code snippet. You 'll get an idea.

REPORT ztest.

DATA: l_alv TYPE REF TO cl_gui_alv_grid,

lt_mara TYPE TABLE OF mara.

SELECT * FROM mara INTO TABLE lt_mara.

  • Creation of the ALV object, when we use cl_gui_container=>screen0 as parent, the ALVGrid control will

  • automatically use the full screen to display the grid, NO CONTAINER DEFINITION IS REQUIRED !

CREATE OBJECT l_alv

EXPORTING i_parent = cl_gui_container=>screen0.

  • calling the display of the grid, the system will automatically create the fieldcatalog based

  • on the table name you pass in parameter

CALL METHOD l_alv->set_table_for_first_display

EXPORTING i_structure_name = 'MARA'

CHANGING it_outtab = lt_mara.

  • You have to create an EMPTY screen, put NOTHING in the layout and this is going to workCALL SCREEN 100

*Instead of creating an empty screen 100, you can also define an empty selection screen in you program and use it, no more screen painter required !

SELECTION-SCREEN BEGIN OF SCREEN 1001.

SELECTION-SCREEN END OF SCREEN 1001.

CALL SELECTION-SCREEN 1001.

Regards,

Arun Prasath Kumar.

Read only

Former Member
0 Likes
731

Hi,

This is possible,

use alv for this

alv_grid_display

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

  • EXPORTING

  • I_INTERFACE_CHECK = ' '

  • I_BYPASSING_BUFFER = ' '

  • I_BUFFER_ACTIVE = ' '

  • I_CALLBACK_PROGRAM = ' '

  • I_CALLBACK_PF_STATUS_SET = ' '

  • I_CALLBACK_USER_COMMAND = ' '

  • I_CALLBACK_TOP_OF_PAGE = ' '

  • I_CALLBACK_HTML_TOP_OF_PAGE = ' '

  • I_CALLBACK_HTML_END_OF_LIST = ' '

  • I_STRUCTURE_NAME = mara (here give your structure name)

  • I_BACKGROUND_ID = ' '

  • I_GRID_TITLE =

  • I_GRID_SETTINGS =

  • IS_LAYOUT =

  • IT_FIELDCAT =

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

  • IT_SORT =

  • IT_FILTER =

  • IS_SEL_HIDE =

  • I_DEFAULT = 'X'

  • I_SAVE = ' '

  • IS_VARIANT =

  • IT_EVENTS =

  • IT_EVENT_EXIT =

  • IS_PRINT =

  • IS_REPREP_ID =

  • I_SCREEN_START_COLUMN = 0

  • I_SCREEN_START_LINE = 0

  • I_SCREEN_END_COLUMN = 0

  • I_SCREEN_END_LINE = 0

  • I_HTML_HEIGHT_TOP = 0

  • I_HTML_HEIGHT_END = 0

  • IT_ALV_GRAPHICS =

  • IT_HYPERLINK =

  • IT_ADD_FIELDCAT =

  • IT_EXCEPT_QINFO =

  • IR_SALV_FULLSCREEN_ADAPTER =

  • IMPORTING

  • E_EXIT_CAUSED_BY_CALLER =

  • ES_EXIT_CAUSED_BY_USER =

TABLES

t_outtab =

  • EXCEPTIONS

  • PROGRAM_ERROR = 1

  • OTHERS = 2

.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

Read only

kesavadas_thekkillath
Active Contributor
0 Likes
731

Check this


DATA:wa_mara TYPE mara.
DATA:wa_str TYPE string.

SELECT * FROM mara INTO wa_mara UP TO 1 ROWS.
ENDSELECT.

CALL METHOD cl_abap_container_utilities=>fill_container_c
  EXPORTING
    im_value               = wa_mara
  IMPORTING
    ex_container           = wa_str
  EXCEPTIONS
    illegal_parameter_type = 1
    OTHERS                 = 2.

WRITE wa_str.

Read only

Former Member
0 Likes
731

Hi,

Using write statements we can print/display data object of type STRING and all structure types are treated as CHAR data type.

So in ABAP without using class you cannot print all the entries or set of entry as mentioned by you.

So you can print details by creating data objects by using ABAP Objects(Class) and by mentioning that in Write statement .

Regards,

Renuka.