Professional Documents
Culture Documents
Z Fieldinfo
Z Fieldinfo
REPORT Z_FIELDINFO.
FIELD-SYMBOLS:
<dyn_tab> TYPE ANY TABLE,
<DYN_TABLE> TYPE STANDARD TABLE,
<DESR_COMP> TYPE ABAP_COMPDESCR,
<MY_FS> TYPE ANY.
* Grid title.
data : text2 type string.
* Selection screen
selection-screen begin of block blk with frame.
*HERE ENTER THE TABLE NAME
parameters : p_table like dd02l-tabname,
*HERE ENTER THE PATH WHERE YOU HAVE TO DOWNLOAD YOUR FILE
*please enter the file as XLS extension as we download
*the data in DAT format as 'C:\temp\file.xls'
p_file like rlgrap-filename.
selection-screen end of block blk.
*initialization event
INITIALIZATION.
*Appending the values fetched through the Function module in the output
*Alv report
loop at it_fies into wa_fies.
wa_output-fieldname = wa_fies-fieldname.
wa_output-inttype = wa_fies-inttype.
wa_OUTPUT-MEMORYID = wa_FIES-MEMORYID.
wa_OUTPUT-CHECKTABLE = wa_fies-checktable.
wa_OUTPUT-LENG = wa_FIES-LENG.
wa_output-fieldtext = wa_fies-fieldtext.
wa_output-keyflag = wa_fies-keyflag.
wa_output-convexit = wa_fies-convexit.
wa_output-domname = wa_fies-domname.
wa_output-rollname = wa_fies-rollname.
if wa_fies-keyflag = 'X'.
wa_output-color_line = 'C600'.
endif.
text2 = wa_desc-ddtext.
*On this statement double click it takes you to the screen painter SE51
*.Enter the attributes
*Create a Custom container and name it C_CONT and OK code as OK_CODE.
*Save check and Activate the scren painter.
*NOw a normal screen witn number 600 is created which holds the ALV grid
*PBO of the actual screen,Here we can give a title and customized menus
*Go to SE41 and create status GETZ and create THE function code 'LIST'
*and 'EXIT' with icons and icon texts
*Also create a TitleBar ALV and give the relevant title.
*&---------------------------------------------------------------------*
*& Module STATUS_0600 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE STATUS_0600 OUTPUT.
SET PF-STATUS 'GETZ'. "Defining own PF status
SET TITLEBAR 'ALV'. "Defining a title
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_0600 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE USER_COMMAND_0600 INPUT.
case sy-ucomm.
when 'LIST'.
PERFORM LIST_DOWNLOAD.
WHEN 'EXIT'.
leave program.
endcase.
*&---------------------------------------------------------------------*
*& Form alv_build_fieldcat
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* field catalogue build
*----------------------------------------------------------------------*
FORM alv_build_fieldcat.
CLEAR lv_fldcat.
lv_fldcat-row_pos = '1'.
lv_fldcat-col_pos = '1'.
lv_fldcat-fieldname = 'FIELDNAME'.
lv_fldcat-tabname = 'IT_OUTPUT'.
lv_fldcat-outputlen = 15.
lv_fldcat-scrtext_m = 'Fieldname'.
lv_fldcat-icon = 'X'.
APPEND lv_fldcat TO it_fcat.
CLEAR lv_fldcat.
lv_fldcat-row_pos = '1'.
lv_fldcat-col_pos = '2'.
lv_fldcat-fieldname = 'INTTYPE'.
lv_fldcat-tabname = 'IT_OUTPUT'.
lv_fldcat-outputlen = 5.
lv_fldcat-scrtext_m = 'Datatype'.
lv_fldcat-icon = ''.
APPEND lv_fldcat TO it_fcat.
CLEAR lv_fldcat.
lv_fldcat-row_pos = '1'.
lv_fldcat-col_pos = '3'.
lv_fldcat-fieldname = 'LENG'.
lv_fldcat-tabname = 'IT_OUTPUT'.
lv_fldcat-outputlen = 5.
lv_fldcat-scrtext_m = 'Length'.
lv_fldcat-icon = ''.
APPEND lv_fldcat TO it_fcat.
CLEAR lv_fldcat.
lv_fldcat-row_pos = '1'.
lv_fldcat-col_pos = '4'.
lv_fldcat-fieldname = 'FIELDTEXT'.
lv_fldcat-tabname = 'IT_OUTPUT'.
lv_fldcat-outputlen = 60.
lv_fldcat-scrtext_m = 'Description'.
lv_fldcat-icon = ''.
APPEND lv_fldcat TO it_fcat.
CLEAR lv_fldcat.
lv_fldcat-row_pos = '1'.
lv_fldcat-col_pos = '6'.
lv_fldcat-fieldname = 'MEMORYID'.
lv_fldcat-tabname = 'IT_OUTPUT'.
lv_fldcat-outputlen = 5.
lv_fldcat-scrtext_m = 'ParameterID'.
lv_fldcat-icon = ''.
APPEND lv_fldcat TO it_fcat.
CLEAR lv_fldcat.
lv_fldcat-row_pos = '1'.
lv_fldcat-col_pos = '7'.
lv_fldcat-fieldname = 'CHECKTABLE'.
lv_fldcat-tabname = 'IT_OUTPUT'.
lv_fldcat-outputlen = 8.
lv_fldcat-scrtext_m = 'Checktable'.
lv_fldcat-icon = ''.
APPEND lv_fldcat TO it_fcat.
CLEAR lv_fldcat.
lv_fldcat-row_pos = '1'.
lv_fldcat-col_pos = '8'.
lv_fldcat-fieldname = 'DOMNAME'.
lv_fldcat-tabname = 'IT_OUTPUT'.
lv_fldcat-outputlen = 8.
lv_fldcat-scrtext_m = 'Domain'.
lv_fldcat-icon = ''.
APPEND lv_fldcat TO it_fcat.
CLEAR lv_fldcat.
lv_fldcat-row_pos = '1'.
lv_fldcat-col_pos = '9'.
lv_fldcat-fieldname = 'ROLLNAME'.
lv_fldcat-tabname = 'IT_OUTPUT'.
lv_fldcat-outputlen = 8.
lv_fldcat-scrtext_m = 'DataElement'.
lv_fldcat-icon = ''.
APPEND lv_fldcat TO it_fcat.
CLEAR lv_fldcat.
lv_fldcat-row_pos = '1'.
lv_fldcat-col_pos = '10'.
lv_fldcat-fieldname = 'CONVEXIT'.
lv_fldcat-tabname = 'IT_OUTPUT'.
lv_fldcat-outputlen = 8.
lv_fldcat-scrtext_m = 'Conversion Routine'.
lv_fldcat-icon = ''.
APPEND lv_fldcat TO it_fcat.
endform. "LIST_DOWNLOAD
*---------------------------------------------------------------------*
* FORM DOWNLOAD_TABLE *
*---------------------------------------------------------------------*
* Downloads the table data.
*---------------------------------------------------------------------*
FORM DOWNLOAD_TABLE.
IF SY-SUBRC EQ 0.
*POP up to inform is download is successful or not
CALL FUNCTION 'POPUP_TO_INFORM'
EXPORTING
TITEL = 'Success!'
TXT1 = p_table
TXT2 = 'was correctly downloaded.'.
ELSE.
CALL FUNCTION 'POPUP_TO_INFORM'
EXPORTING
TITEL = 'Error!'
TXT1 = p_table
TXT2 = 'NOT downloaded.'.
ENDIF.
ENDFORM. "DOWNLOAD_TABLE
*---------------------------------------------------------------------*
* FORM CREATE_TABLE *
*---------------------------------------------------------------------*
* Creates a dynamic internal table.
*---------------------------------------------------------------------*
FORM CREATE_TABLE.
CREATE DATA DATAREFERENCE TYPE (P_TABLE).
Execute
You will get a POP UP saying the Table name and it description.
Click Continue
We get the ALV output with the list of all fields in the table with their characteristics.
The pink colored fields are the key fields in the table.
The values get downloaded into the specified file with fieldnames as the column
headings.
A pop up appears as