2007 Dec 27 9:06 AM
hi experts,
I have a requirement which is
I have to select the first 10 fields of any database table which will be given in the selection screen except the first field 'MANDT' .
after selection the report should be displayed in ALV.
then in the report which is generated if i select any one record the details of that particular record should be vertically displayed in a pop up.
if multiple records are selected the data should be displayed horizontally in a pop up.
if any sample code is there pls send me ASAP.
the requirement is very urgent.
Thanks in advance
hi experts,
I have a requirement which is
I have to select the first 10 fields of any database table which will be given in the selection screen except the first field 'MANDT' .
after selection the report should be displayed in ALV.
then in the report which is generated if i select any one record the details of that particular record should be vertically displayed in a pop up.
if multiple records are selected the data should be displayed horizontally in a pop up.
if any sample code is there pls send me ASAP.
the requirement is very urgent.
Thanks in advance
2007 Dec 27 9:13 AM
Hi ,
I think for your first requirement you will have to check the code for Dynamic internal table.
You will find this in many forum threads .
This code will help you to create ALV with the first 10 fields of the given table .
Once the table with contents is prepared jst delete the record for field 'MANDT'
I am not sure abt the second requirement.
Thanks,
Poonam.
2007 Dec 27 9:43 AM
Hi Krithika,
Check this code. this might help in solving your problem.
>********************************************************************
This report displays data from SAP tables (like SE16) *
FM : REUSE_ALV_GRID_DISPLAY
***********************************************************************
DATA:
g_mandt TYPE mandt.
SELECTION-SCREEN :
BEGIN OF LINE, COMMENT 6(33) v_1 FOR FIELD p_table. "#EC NEEDED
PARAMETERS p_table TYPE dd03l-tabname OBLIGATORY MEMORY ID dtb.
SELECTION-SCREEN : END OF LINE, SKIP.
SELECTION-SCREEN :
BEGIN OF LINE, COMMENT 6(30) v_2 FOR FIELD s_mandt. "#EC NEEDED
SELECT-OPTIONS s_mandt FOR g_mandt DEFAULT sy-mandt
MATCHCODE OBJECT ddsef4clnt.
SELECTION-SCREEN : END OF LINE, SKIP.
SELECTION-SCREEN :
SKIP , BEGIN OF LINE, COMMENT 6(33) v_3 FOR FIELD p_max. "#EC NEEDED
PARAMETERS p_max(3) TYPE n DEFAULT '200' OBLIGATORY.
SELECTION-SCREEN END OF LINE.
----
AT SELECTION-SCREEN.
PERFORM f_check_table.
----
INITIALIZATION.
v_1 = 'Table'.
v_2 = 'Client'.
v_3 = 'Maximum of records'.
----
START-OF-SELECTION.
PERFORM f_display_data.
----
Form F_DISPLAY_DATA
----
FORM f_display_data.
TYPE-POOLS: slis. " ALV Global Types
DATA:
lp_table TYPE REF TO data, " Pointer to dynamic table
ls_layout TYPE slis_layout_alv,
lt_fieldcat TYPE slis_t_fieldcat_alv.
FIELD-SYMBOLS :
<lt_data> TYPE STANDARD TABLE. " Data to display
Create internal table
CREATE DATA lp_table TYPE STANDARD TABLE OF (p_table)
WITH NON-UNIQUE DEFAULT KEY.
ASSIGN lp_table->* TO <lt_data>.
Field MANDT exists ?
SELECT SINGLE tabname
INTO p_table
FROM dd03l
WHERE tabname = p_table
AND fieldname = 'MANDT'
AND as4local = 'A'
AND as4vers = '0000'
AND position = '0001'
AND rollname = 'MANDT'.
IF sy-subrc EQ 0.
Read data
SELECT * UP TO p_max ROWS
FROM (p_table) CLIENT SPECIFIED
INTO CORRESPONDING FIELDS OF TABLE <lt_data>
WHERE mandt IN s_mandt
ORDER BY PRIMARY KEY.
ELSE.
Field CLIENT exists ?
SELECT SINGLE tabname
INTO p_table
FROM dd03l
WHERE tabname = p_table
AND fieldname = 'CLIENT'
AND as4local = 'A'
AND as4vers = '0000'
AND position = '0001'
AND rollname = 'MANDT'.
IF sy-subrc EQ 0.
Read data
SELECT * UP TO p_max ROWS
FROM (p_table) CLIENT SPECIFIED
INTO CORRESPONDING FIELDS OF TABLE <lt_data>
WHERE client IN s_mandt
ORDER BY PRIMARY KEY.
ELSE.
Read data
SELECT * UP TO p_max ROWS
FROM (p_table)
INTO CORRESPONDING FIELDS OF TABLE <lt_data>
ORDER BY PRIMARY KEY.
ENDIF.
ENDIF.
IF <lt_data>[] IS INITIAL.
No table entries found for specified key
MESSAGE i429(mo).
EXIT.
ENDIF.
Build Field catalog
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_structure_name = p_table
i_client_never_display = ''
CHANGING
ct_fieldcat = lt_fieldcat
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ls_layout-zebra = 'X'.
ls_layout-colwidth_optimize = 'X'.
Display ALV List
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
is_layout = ls_layout
it_fieldcat = lt_fieldcat
TABLES
t_outtab = <lt_data>.
ENDFORM. " F_DISPLAY_DATA
----
Form F_CHECK_TABLE
----
FORM f_check_table.
DATA :
l_tabclass TYPE tabclass, " Table category
l_viewclass TYPE viewclass. " View Type
Read table category
SELECT SINGLE tabclass viewclass
INTO (l_tabclass, l_viewclass)
FROM dd02l
WHERE tabname = p_table
AND as4local = 'A'
AND as4vers = '0000'.
IF sy-subrc NE 0.
Table & is not active in the Dictionary
MESSAGE e402(mo) WITH p_table.
ELSEIF l_tabclass = 'INTTAB'.
& is a structure, not a table
MESSAGE e403(mo) WITH p_table.
ELSEIF l_tabclass = 'VIEW' AND l_viewclass NE 'D'.
Only use views of type "Maintenance view"
MESSAGE e309(sv).
ENDIF.
ENDFORM. " F_CHECK_TABLE
Reward Points, if useful.
Regards,
Manoj Kumar
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |