This program is meant to maintain Z* or Y* tables only but i have a EXCEPTION table where you can maintain any table name other than Z* or Y* and then you
can maintain that table using this tool (Not Recommended) Table name for maintaining exceptions is ZBC_EXCEPLOAD and the structure is as below:
MANDT MANDT CLNT 3 0 Client
TABNAME TABNAME CHAR 30 0 Table Name
I have controlled it for viewing purpose as well maintenance using the authorization object ZRDM000001 with field ACTION. Create once screen 100 with a custom
container ALV_CONTAINER. Create a PF Status 'STLI' and assign codes EDIT, DISP, BACK, %EX, RW to that.
container ALV_CONTAINER. Create a PF Status 'STLI' and assign codes EDIT, DISP, BACK, %EX, RW to that.
Code is given below:
PROGRAM zbc_maintain_check_tables NO STANDARD PAGE HEADING LINE-COUNT 65 LINE-SIZE 1023.
TABLES: sscrfields, "Fields on selection screens
dd01l,
dd02l,
dd03l,
dd03vt,
zbc_excepload.
TYPE-POOLS: rsds, truxs.
DATA ds_clauses TYPE rsds_where.
DATA: BEGIN OF ds_where OCCURS 0,
line(72),
END OF ds_where.
DATA: text TYPE string.
DATA: sl_index LIKE sy-tabix.
DATA: lt_exclude TYPE ui_functions.
DATA: lt_dd03l LIKE dd03l OCCURS 0 WITH HEADER LINE.
DATA: num TYPE i,
max_len TYPE i,
check_len TYPE i,
sl_sel TYPE c.
DATA: gv_file LIKE rlgrap-filename,
gv_rec_read TYPE i,
gv_rec_proc TYPE i,
gv_rec_load TYPE i,
gv_rec_dele TYPE i,
gv_rec_dupl TYPE i,
gv_rec_chan TYPE i,
gv_rec_nonp TYPE i.
DATA: lt_dfies TYPE ddfields,
ls_dfies TYPE dfies.
FIELD-SYMBOLS:TYPE ANY.
***********************************************************************
* CLASS cl_event_receiver DEFINITION
***********************************************************************
CLASS cl_event_receiver DEFINITION.
PUBLIC SECTION.
METHODS:
handle_user_command
FOR EVENT user_command OF cl_gui_alv_grid
IMPORTING e_ucomm,
handle_toolbar
FOR EVENT toolbar OF cl_gui_alv_grid
IMPORTING e_object,
handle_double_click
FOR EVENT double_click OF cl_gui_alv_grid
IMPORTING e_row e_column.
PRIVATE SECTION.
ENDCLASS. "CL_EVENT_RECEIVER DEFINITION
*----------------------------------------------------------------------*
* CLASS cl_event_receiver IMPLEMENTATION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS cl_event_receiver IMPLEMENTATION.
METHOD handle_double_click.
PERFORM drill_down USING e_row-index e_column.
ENDMETHOD. "handle_double_click
METHOD handle_toolbar.
PERFORM handle_toolbar USING e_object.
ENDMETHOD. "handle_toolbar
METHOD handle_user_command.
CASE e_ucomm.
WHEN 'CCCP'.
PERFORM update_table.
ENDCASE.
ENDMETHOD. "handle_user_command
ENDCLASS. "CL_EVENT_RECEIVER IMPLEMENTATION
DATA: event_receiver TYPE REF TO cl_event_receiver.
DATA: alv_grid TYPE REF TO cl_gui_alv_grid.
DATA: alv_container TYPE REF TO cl_gui_custom_container.
DATA: fieldcat TYPE lvc_t_fcat.
DATA: layout TYPE lvc_s_layo.
DATA: fc TYPE lvc_s_fcat.
DATA: gs_variant TYPE disvariant,
gt_top_of_page TYPE slis_t_listheader.
DATA: lt_cells TYPE lvc_t_moce.
DATA: l_ans(1).
DATA: tabnameh TYPE dd02l-tabname.
TYPE-POOLS: icon.
FIELD-SYMBOLS:TYPE STANDARD TABLE.
FIELD-SYMBOLS:TYPE STANDARD TABLE.
FIELD-SYMBOLS:TYPE STANDARD TABLE.
FIELD-SYMBOLS:TYPE ANY TABLE.
FIELD-SYMBOLS:TYPE ANY TABLE.
FIELD-SYMBOLS:TYPE ANY TABLE.
DEFINE show_alv.
*--- &1, Container
*--- &2, Container ID
*--- &3, ALV Layout
*--- &4, ALV Display Variant
*--- &5, Table to display in ALV
*--- &6, ALV Field Catalouge
*--- &7, ALV Grid ID
*--- Create Object Container
if &1 is initial.
create object &1
exporting
container_name = &2.
*--- Create Object ALV Grid assigning container
create object &7
exporting
i_parent = &1.
*--- Create Event Receiver
create object event_receiver.
*--- Assign methods for event handling
set handler event_receiver->handle_toolbar for &7.
set handler event_receiver->handle_user_command for &7.
set handler event_receiver->handle_double_click for &7.
*--- Exclude toolbar buttons
perform exclude_tb_functions changing lt_exclude.
*--- Display ALV Grid Report
call method &7->set_table_for_first_display
exporting
is_layout = &3
is_variant = &4
i_save = 'A'
it_toolbar_excluding = lt_exclude
changing
it_outtab = &5
it_fieldcatalog = &6.
call method &7->set_ready_for_input
exporting
i_ready_for_input = 0.
else.
set handler event_receiver->handle_toolbar for &7.
call method &7->refresh_table_display.
endif.
*--- Set focus to the active ALV Grid
call method &7->set_toolbar_interactive.
call method cl_gui_control=>set_focus
exporting
control = &7.
END-OF-DEFINITION.
*----------------------------------------------------------------*
* SELECTION-SCREEN.
*----------------------------------------------------------------*
SELECTION-SCREEN BEGIN OF BLOCK block_1 WITH FRAME.
SELECTION-SCREEN BEGIN OF LINE.
* text-012 - 'Table Name'
SELECTION-SCREEN COMMENT 1(33) text-012.
PARAMETERS: tabname LIKE dd02l-tabname DEFAULT 'Z'.
* text-003 - 'Selection'
SELECTION-SCREEN: PUSHBUTTON 70(20) selopt USER-COMMAND sta1.
SELECTION-SCREEN END OF LINE.
* numrows(text) - 'Max Number of ROWS'
PARAMETERS: numrows LIKE sy-subrc.
PARAMETERS: xoutput LIKE layout-frontend DEFAULT 'G'.
PARAMETERS: upload AS CHECKBOX DEFAULT ''.
SELECTION-SCREEN END OF BLOCK block_1.
************************************************************************
* At Selection-Screen *
************************************************************************
AT SELECTION-SCREEN.
SELECT SINGLE tabname
INTO tabname
FROM dd02l
WHERE tabname = tabname
AND as4local = 'A'
AND ( tabclass = 'TRANSP' OR tabclass = 'POOL'
OR tabclass = 'CLUSTER' ).
IF sy-subrc <> 0.
MESSAGE 'Table is not valid' TYPE 'S'.
RETURN.
ENDIF.
SELECT SINGLE * FROM zbc_excepload WHERE tabname = tabname.
IF sy-subrc <> 0.
IF tabname+0(1) <> 'Z' AND tabname+0(1) <> 'Y'.
MESSAGE 'This utility is meant for only customer name space Z* and Y*' TYPE 'E'.
RETURN.
ENDIF.
ENDIF.
CASE sscrfields-ucomm.
WHEN 'STA1'.
CLEAR sl_sel.
CALL FUNCTION 'ZBC_FREE_TABLE_SELECTIONS'
EXPORTING
tabname = tabname
IMPORTING
ds_clauses = ds_clauses
EXCEPTIONS
table_not_valid = 1
other_error = 2
OTHERS = 3.
IF sy-subrc = 0.
sl_sel = 'X'.
ENDIF.
ENDCASE.
*----------------------------------------------------------------*
* INITIALIZATION.
*----------------------------------------------------------------*
INITIALIZATION.
MOVE ' (4G) Filter records' TO selopt.
*----------------------------------------------------------------*
* START-OF-SELECTION.
*----------------------------------------------------------------*
START-OF-SELECTION.
FIELD-SYMBOLS:TYPE ANY.
CONDENSE tabname.
SELECT SINGLE tabname
INTO tabname
FROM dd02l
WHERE tabname = tabname
AND as4local = 'A'
AND ( tabclass = 'TRANSP' OR tabclass = 'POOL'
OR tabclass = 'CLUSTER' ).
IF sy-subrc <> 0.
MESSAGE 'Table is not valid' TYPE 'S'.
RETURN.
ENDIF.
PERFORM alv_set_layout. "Define ALV Layout
PERFORM alv_set_fieldcat. "Create ALV field catalogue for initial display
PERFORM mydyntable USING fieldcat. "Create Dynamic tables based on DB table name to be updated
IFIS ASSIGNED.
CALL FUNCTION 'DDIF_FIELDINFO_GET'
EXPORTING
tabname = tabname
TABLES
dfies_tab = lt_dfies
EXCEPTIONS
not_found = 1
internal_error = 2
OTHERS = 3.
ENDIF.
IF upload = 'X'.
CALL FUNCTION 'POPUP_TO_DECIDE'
EXPORTING
defaultoption = 'A'
textline1 = text-o01
textline2 = text-o02
textline3 = text-o03
text_option1 = text-o07
text_option2 = text-o08
titel = text-o10
start_column = 25
start_row = 6
cancel_display = 'X'
IMPORTING
answer = l_ans.
ELSE.
IF sl_sel = 'X'.
SELECT *
FROM (tabname)
INTO CORRESPONDING FIELDS OF TABLEUP TO numrows ROWS
WHERE (ds_clauses-where_tab).
ELSE.
SELECT *
FROM (tabname)
INTO CORRESPONDING FIELDS OF TABLEUP TO numrows ROWS.
ENDIF.
[] = [].
ENDIF.
CASE l_ans.
WHEN '1'.
AUTHORITY-CHECK OBJECT 'ZRDM000001'
ID 'ACTION' FIELD 'A'.
IF sy-subrc = 0.
AUTHORITY-CHECK OBJECT 'ZRDM000001'
ID 'ACTION' FIELD 'C'.
IF sy-subrc = 0.
* Locating the file path and filename on the selection screen
CALL FUNCTION 'F4_FILENAME'
EXPORTING
program_name = syst-cprog
dynpro_number = syst-dynnr
IMPORTING
file_name = gv_file.
PERFORM update_table_from_file.
ELSE.
MESSAGE e004(zrp).
* No Authorisation to Create/Change...
ENDIF.
ELSE.
MESSAGE e004(zrp).
* No Authorisation to Create/Change...
ENDIF.
WHEN '2'.
AUTHORITY-CHECK OBJECT 'ZRDM000001'
ID 'ACTION' FIELD 'A'
ID 'ACTION' FIELD 'C'.
IF sy-subrc = 0.
* Locating the file path and filename on the selection screen
CALL FUNCTION 'F4_FILENAME'
EXPORTING
program_name = syst-cprog
dynpro_number = syst-dynnr
IMPORTING
file_name = gv_file.
SELECT *
FROM (tabname)
INTO CORRESPONDING FIELDS OF TABLE.
AUTHORITY-CHECK OBJECT 'ZRDM000001'
ID 'ACTION' FIELD 'E'.
IF sy-subrc = 0.
PERFORM delete_table.
PERFORM update_table_from_file.
ELSE.
MESSAGE e005(zrp).
* No Authorisation to Delete...
ENDIF.
ELSE.
MESSAGE e004(zrp).
* No Authorisation to Create/Change...
ENDIF.
WHEN 'A'.
WHEN OTHERS.
CALL SCREEN 100.
ENDCASE.
IFIS ASSIGNED.
UNASSIGN.
ENDIF.
IF upload = 'X'.
WRITE:/ 'Records read from File : ', gv_rec_read.
WRITE:/ 'Records processed : ', gv_rec_proc.
WRITE:/ 'Records with errors : ', gv_rec_nonp.
ENDIF.
IF gv_rec_proc <> 0..
WRITE:/ 'Duplicates Processed : ', gv_rec_dupl.
DESCRIBE TABLELINES gv_rec_dele.
WRITE:/ 'Records deleted : ', gv_rec_dele.
DESCRIBE TABLELINES gv_rec_load.
WRITE:/ 'Records updated / inserted: ', gv_rec_load.
WRITE:/ 'Details of records deleted as below:'.
LOOP ATASSIGNING .
WRITE:/'Deleted'.
LOOP AT lt_dfies INTO ls_dfies.
ASSIGN COMPONENT ls_dfies-fieldname OF STRUCTURETO .
*= ld_string+ls_dfies-offset(ls_dfies-intlen).
WRITE:.
ENDLOOP.
ENDLOOP.
WRITE:/ 'Details of records Updated / Inserted: '.
LOOP ATASSIGNING .
WRITE:/ 'Updated / Inserted'.
LOOP AT lt_dfies INTO ls_dfies.
ASSIGN COMPONENT ls_dfies-fieldname OF STRUCTURETO .
WRITE:.
ENDLOOP.
ENDLOOP.
ENDIF.
*&---------------------------------------------------------------------*
*& Module STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE status_0100 OUTPUT.
* Standard list status with 'SAVE' button
SET PF-STATUS 'STLI'.
gs_variant-report = sy-repid.
gs_variant-handle = space.
gs_variant-log_group = space.
gs_variant-username = space.
gs_variant-text = space.
gs_variant-dependvars = space.
show_alv alv_container 'ALV_CONTAINER' layout gs_variant[] fieldcat[] alv_grid.
ENDMODULE. " STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_0100 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE user_command_0100 INPUT.
CASE sy-ucomm.
WHEN 'EDIT'.
AUTHORITY-CHECK OBJECT 'ZRDM000001'
ID 'ACTION' FIELD 'A'
ID 'ACTION' FIELD 'C'
ID 'ACTION' FIELD 'E'.
IF sy-subrc = 0.
CALL METHOD alv_grid->set_ready_for_input
EXPORTING
i_ready_for_input = 1.
ELSE.
MESSAGE e004(zrp).
* No Authorisation to Create/Change...
CALL METHOD alv_grid->set_ready_for_input
EXPORTING
i_ready_for_input = 0.
ENDIF.
WHEN 'DISP'.
CALL METHOD alv_grid->set_ready_for_input
EXPORTING
i_ready_for_input = 0.
WHEN '%EX' OR 'BACK'.
CALL METHOD alv_container->free.
CLEAR: alv_container.
FREE : alv_container.
SET SCREEN 0.
LEAVE SCREEN.
WHEN 'RW'.
CALL METHOD alv_container->free.
CLEAR: alv_container.
FREE : alv_container.
LEAVE PROGRAM.
WHEN OTHERS.
ENDCASE.
ENDMODULE. " USER_COMMAND_0100 INPUT
*&---------------------------------------------------------------------*
*& Form alv_set_layout
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM alv_set_layout.
*... Display options
layout-zebra = 'X'.
layout-excp_conds = 'X'.
layout-cwidth_opt = ''.
layout-frontend = xoutput.
ENDFORM. "alv_set_layout
*&---------------------------------------------------------------------*
*& Form alv_set_fieldcat
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM alv_set_fieldcat .
REFRESH: fieldcat.
DATA: v_text(40), lv_index LIKE sy-index.
DATA: v_h1(40),v_h2(40),v_h3(40),v_h4(40),v_h5(40).
FIELD-SYMBOLS:TYPE ANY.
ASSIGN tabname TO.
IFIS ASSIGNED.
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
i_buffer_active = ''
i_structure_name =
i_client_never_display = ''
CHANGING
ct_fieldcat = fieldcat
EXCEPTIONS
inconsistent_interface = 1
program_error = 2.
UNASSIGN.
LOOP AT fieldcat INTO fc.
SELECT SINGLE * FROM dd03vt
WHERE tabname = tabname AND fieldname = fc-fieldname
AND ddlanguage = sy-langu.
fc-rollname = dd03vt-rollname.
fc-checktable = dd03vt-checktable.
IF fc-key = 'X'.
CONCATENATE '*' dd03vt-scrtext_s INTO fc-scrtext_s SEPARATED BY space.
CONCATENATE '*' dd03vt-scrtext_m INTO fc-scrtext_m SEPARATED BY space.
CONCATENATE '*' dd03vt-scrtext_l INTO fc-scrtext_l SEPARATED BY space.
CONCATENATE '*' dd03vt-reptext INTO fc-reptext SEPARATED BY space.
CONCATENATE '*' dd03vt-reptext INTO fc-seltext SEPARATED BY space.
MOVE dd03vt-scrtext_l TO fc-tooltip.
ELSE.
MOVE: dd03vt-scrtext_s TO fc-scrtext_s,
dd03vt-scrtext_m TO fc-scrtext_m,
dd03vt-scrtext_l TO fc-scrtext_l,
dd03vt-reptext TO fc-reptext,
dd03vt-reptext TO fc-seltext,
dd03vt-scrtext_l TO fc-tooltip.
ENDIF.
IF fc-checktable IS INITIAL OR fc-checktable = '*'.
SELECT SINGLE entitytab INTO fc-checktable FROM dd01l WHERE domname = fc-domname.
ENDIF.
IF fc-fieldname <> 'MANDT'.
fc-edit = 'X'.
ENDIF.
MODIFY fieldcat FROM fc.
ENDLOOP.
ENDIF.
ENDFORM. " alv_set_fieldcat
*&---------------------------------------------------------------------*
*& Form exclude_tb_functions
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->PT_EXCLUDE text
*----------------------------------------------------------------------*
FORM exclude_tb_functions CHANGING pt_exclude TYPE ui_functions.
DATA ls_exclude TYPE ui_func.
ls_exclude = cl_gui_alv_grid=>mc_fc_check.
APPEND ls_exclude TO pt_exclude.
ls_exclude = cl_gui_alv_grid=>mc_fc_help.
APPEND ls_exclude TO pt_exclude.
ls_exclude = cl_gui_alv_grid=>mc_fc_detail.
APPEND ls_exclude TO pt_exclude.
ls_exclude = cl_gui_alv_grid=>mc_fc_sum.
APPEND ls_exclude TO pt_exclude.
ls_exclude = cl_gui_alv_grid=>mc_fc_subtot.
APPEND ls_exclude TO pt_exclude.
ls_exclude = cl_gui_alv_grid=>mc_fc_info.
APPEND ls_exclude TO pt_exclude.
ENDFORM. "EXCLUDE_TB_FUNCTIONS
*&---------------------------------------------------------------------*
*& Form handle_toolbar
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->I_OBJECT text
*----------------------------------------------------------------------*
FORM handle_toolbar USING i_object TYPE REF TO cl_alv_event_toolbar_set .
*--- This code adds the Pushbutton for comparison to the ALV Grid toolbar
DATA: ls_toolbar TYPE stb_button.
CLEAR ls_toolbar.
MOVE 3 TO ls_toolbar-butn_type.
APPEND ls_toolbar TO i_object->mt_toolbar.
CLEAR ls_toolbar.
MOVE 0 TO ls_toolbar-butn_type.
MOVE 'CCCP' TO ls_toolbar-function. "#EC NOTEXT
MOVE icon_system_save TO ls_toolbar-icon.
MOVE 'Save Changed Data'(201) TO ls_toolbar-quickinfo.
IF sy-ucomm = 'EDIT'.
MOVE ' ' TO ls_toolbar-disabled. "#EC NOTEXT
ELSE.
MOVE 'X' TO ls_toolbar-disabled. "#EC NOTEXT
ENDIF.
APPEND ls_toolbar TO i_object->mt_toolbar.
ENDFORM . "handle_toolbar
*&---------------------------------------------------------------------*
*& Form update_table
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text *----------------------------------------------------------------------* FORM update_table . DATA: l_answer TYPE c. DATA: l_tabix LIKE sy-tabix. FIELD-SYMBOLS:TYPE ANY,
TYPE ANY.
DATA: lv_answer TYPE c.
DATA: lv_error TYPE c.
DATA: lv_count TYPE i.
DATA: lv_fld(255) TYPE c.
CALL FUNCTION 'POPUP_TO_CONFIRM'
EXPORTING
titlebar = tabname
text_question = 'Update table?'
default_button = '2'
display_cancel_button = ' '
IMPORTING
answer = l_answer
EXCEPTIONS
OTHERS = 1.
IF l_answer = '1'.
*---- Delete all common records fromcomparing
*---- Nowwill have only deleted or changed records and
*---- Nowwill have records which need to updated to table
LOOP ATASSIGNING .
IFIS ASSIGNED.
LOOP ATASSIGNING .
l_tabix = sy-tabix.
IFIS ASSIGNED AND IS ASSIGNED.
IF= .
DELETEINDEX l_tabix.
ENDIF.
ENDIF.
ENDLOOP.
ENDIF.
ENDLOOP.
*--- Delete Records marked for deletion & Change
IF NOT[] IS INITIAL.
DELETE (tabname) FROM TABLE.
ENDIF.
*--- Update Records Marked for change or creation
IF NOT[] IS INITIAL.
LOOP ATASSIGNING .
gv_rec_proc = gv_rec_proc + 1.
REFRESH ds_where.
LOOP AT fieldcat INTO fc WHERE key = 'X' AND fieldname <> 'MANDT'.
ASSIGN COMPONENT fc-fieldname OF STRUCTURETO .
CONDENSE:, fc-fieldname.
CLEAR: lv_fld.
CONCATENATE `'``'` INTO lv_fld.
IF sy-tabix = 2.
CONCATENATE ' ( ' fc-fieldname 'EQ' lv_fld ' )' INTO ds_where-line SEPARATED BY space.
APPEND ds_where.
ELSEIF sy-tabix > 2.
CONCATENATE 'AND' '( ' fc-fieldname 'EQ' lv_fld ' )' INTO ds_where-line SEPARATED BY space.
APPEND ds_where.
ENDIF.
ENDLOOP.
ds_where-line = '.'.
APPEND ds_where.
IFIS ASSIGNED.
SELECT *
FROM (tabname)
INTO CORRESPONDING FIELDS OF TABLEWHERE (ds_where).
IF sy-subrc <> 0.
LOOP AT fieldcat INTO fc WHERE checktable <> ''.
lv_error = 'X'.
FIELD-SYMBOLS:TYPE ANY.
DATA: dref_table_line TYPE REF TO data.
CREATE DATA dref_table_line TYPE (fc-checktable).
ASSIGN dref_table_line->* TO.
IFIS ASSIGNED AND IS ASSIGNED.
REFRESH: ds_where.
ASSIGN COMPONENT fc-fieldname OF STRUCTURETO .
CLEAR: lv_fld.
IFIS ASSIGNED AND NOT IS INITIAL.
SELECT * FROM dd03l WHERE tabname = fc-checktable AND rollname = fc-rollname
AND domname = fc-domname.
REFRESH: ds_where.
IF fc-checktable <> tabname.
CONCATENATE `'``'` INTO lv_fld.
CONCATENATE '( ' dd03l-fieldname 'EQ' lv_fld ' ).' INTO ds_where-line SEPARATED BY space.
APPEND ds_where.
IFIS ASSIGNED AND NOT IS INITIAL.
IF NOT ds_where[] IS INITIAL.
SELECT SINGLE * INTO CORRESPONDING FIELDS OFFROM (fc-checktable) WHERE (ds_where).
IF sy-subrc = 0.
lv_error = ' '.
EXIT.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ENDSELECT.
IF sy-subrc <> 0 AND fc-checktable <> tabname AND lv_error = 'X'.
SELECT * FROM dd03l WHERE tabname = fc-checktable AND domname = fc-domname.
REFRESH: ds_where.
IF sy-subrc = 0 AND fc-checktable <> tabname.
CONCATENATE `'``'` INTO lv_fld.
CONCATENATE '( ' dd03l-fieldname 'EQ' lv_fld ' ).' INTO ds_where-line SEPARATED BY space.
APPEND ds_where.
IFIS ASSIGNED AND NOT IS INITIAL.
IF NOT ds_where[] IS INITIAL.
SELECT SINGLE * INTO CORRESPONDING FIELDS OFFROM (fc-checktable) WHERE (ds_where).
IF sy-subrc = 0.
lv_error = ' '.
EXIT.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ENDSELECT.
ENDIF.
IF lv_error = 'X' AND fc-checktable <> tabname.
lv_count = lv_count + 1.
CONDENSE fc-fieldname.
WRITE:/ 'Field', fc-fieldname, 'value',,'not in table ', fc-checktable.
ENDIF.
ENDIF.
ENDIF.
IFIS ASSIGNED.
UNASSIGN.
ENDIF.
IFIS ASSIGNED.
UNASSIGN.
ENDIF.
ENDLOOP.
IF lv_count = 0.
MODIFY (tabname) FROM.
ELSEIF lv_count <> 0.
lv_count = 0.
WRITE:/ 'Above mentioned errors in this record: ', gv_rec_proc.
LOOP AT lt_dfies INTO ls_dfies.
ASSIGN COMPONENT ls_dfies-fieldname OF STRUCTURETO .
WRITE:.
ENDLOOP.
SKIP.
DELETE.
gv_rec_nonp = gv_rec_nonp + 1.
lv_error = ''.
ENDIF.
ELSE.
WRITE:/ 'Already Exists,Non Key Fields Updated: ', gv_rec_proc.
LOOP AT lt_dfies INTO ls_dfies.
ASSIGN COMPONENT ls_dfies-fieldname OF STRUCTURETO .
WRITE:.
ENDLOOP.
gv_rec_dupl = gv_rec_dupl + 1.
MODIFY (tabname) FROM.
ENDIF.
ENDIF.
ENDLOOP.
ENDIF.
ENDIF.
COMMIT WORK AND WAIT.
ENDFORM. " update_table
*&---------------------------------------------------------------------*
*& Form update_table_from_file
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM update_table_from_file.
FIELD-SYMBOLS:TYPE ANY,
TYPE ANY,
TYPE fieldname.
DATA: lv_answer TYPE c.
DATA: lv_error TYPE c.
DATA: lv_count TYPE i.
DATA: lv_fld(255) TYPE c.
DATA: lv_file TYPE string.
DATA: lv_string(1023).
CALL FUNCTION 'POPUP_TO_CONFIRM'
EXPORTING
titlebar = tabname
text_question = 'Update table based on file ?'
default_button = '2'
display_cancel_button = ' '
IMPORTING
answer = lv_answer
EXCEPTIONS
OTHERS = 1.
IF lv_answer = '1'.
CALL FUNCTION 'POPUP_TO_DECIDE'
EXPORTING
defaultoption = 'A'
textline1 = 'Select type of'
textline2 = 'file to be used'
text_option1 = 'Tab Delimited'
text_option2 = 'Excel Sheet'
icon_text_option1 = 'ICON_WD_TEXT_EDIT'
icon_text_option2 = 'ICON_LIST'
start_column = 25
start_row = 6
cancel_display = ''
titel = 'Option'
IMPORTING
answer = lv_answer.
CASE lv_answer.
WHEN '1'.
MOVE gv_file TO lv_file.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = lv_file
filetype = 'ASC'
has_field_separator = 'X'
read_by_line = 'X'
TABLES
data_tab =
EXCEPTIONS
file_open_error = 1
file_read_error = 2
no_batch = 3
gui_refuse_filetransfer = 4
invalid_type = 5
no_authority = 6
unknown_error = 7
bad_data_format = 8
header_not_allowed = 9
separator_not_allowed = 10
header_too_long = 11
unknown_dp_error = 12
access_denied = 13
dp_out_of_memory = 14
disk_full = 15
dp_timeout = 16.
WHEN '2'.
PERFORM transfer_to_dyntab.
WHEN OTHERS.
ENDCASE.
IF NOT[] IS INITIAL.
DESCRIBE TABLELINES gv_rec_read.
LOOP ATASSIGNING .
gv_rec_proc = gv_rec_proc + 1.
REFRESH ds_where.
LOOP AT fieldcat INTO fc WHERE key = 'X' AND fieldname <> 'MANDT'.
ASSIGN COMPONENT fc-fieldname OF STRUCTURETO .
CONDENSE:, fc-fieldname.
CLEAR: lv_fld.
CONCATENATE `'``'` INTO lv_fld.
IF sy-tabix = 2.
CONCATENATE ' ( ' fc-fieldname 'EQ' lv_fld ' )' INTO ds_where-line SEPARATED BY space.
APPEND ds_where.
ELSEIF sy-tabix > 2.
CONCATENATE 'AND' '( ' fc-fieldname 'EQ' lv_fld ' )' INTO ds_where-line SEPARATED BY space.
APPEND ds_where.
ENDIF.
ENDLOOP.
ds_where-line = '.'.
APPEND ds_where.
IFIS ASSIGNED.
SELECT *
FROM (tabname)
INTO CORRESPONDING FIELDS OF TABLEWHERE (ds_where).
IF sy-subrc <> 0.
LOOP AT fieldcat INTO fc WHERE checktable <> ''.
lv_error = 'X'.
FIELD-SYMBOLS:TYPE ANY.
DATA: dref_table_line TYPE REF TO data.
CREATE DATA dref_table_line TYPE (fc-checktable).
ASSIGN dref_table_line->* TO.
IFIS ASSIGNED AND IS ASSIGNED.
ASSIGN COMPONENT fc-fieldname OF STRUCTURETO .
CLEAR: lv_fld.
IFIS ASSIGNED AND NOT IS INITIAL.
SELECT * FROM dd03l WHERE tabname = fc-checktable AND rollname = fc-rollname
AND domname = fc-domname.
IF fc-checktable <> tabname.
REFRESH: ds_where.
CONCATENATE `'``'` INTO lv_fld.
CONCATENATE '( ' dd03l-fieldname 'EQ' lv_fld ' ).' INTO ds_where-line SEPARATED BY space.
APPEND ds_where.
IFIS ASSIGNED AND NOT IS INITIAL.
IF NOT ds_where[] IS INITIAL.
SELECT SINGLE * INTO CORRESPONDING FIELDS OFFROM (fc-checktable) WHERE (ds_where).
IF sy-subrc = 0.
lv_error = ' '.
EXIT.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ENDSELECT.
IF sy-subrc <> 0 AND fc-checktable <> tabname AND lv_error = 'X'.
SELECT * FROM dd03l WHERE tabname = fc-checktable AND domname = fc-domname.
IF sy-subrc = 0 AND fc-checktable <> tabname.
REFRESH: ds_where.
CONCATENATE `'``'` INTO lv_fld.
CONCATENATE '( ' dd03l-fieldname 'EQ' lv_fld ' ).' INTO ds_where-line SEPARATED BY space.
APPEND ds_where.
IFIS ASSIGNED AND NOT IS INITIAL.
IF NOT ds_where[] IS INITIAL.
SELECT SINGLE * INTO CORRESPONDING FIELDS OFFROM (fc-checktable) WHERE (ds_where).
IF sy-subrc = 0.
lv_error = ' '.
EXIT.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ENDSELECT.
ENDIF.
IF lv_error = 'X' AND fc-checktable <> tabname.
lv_count = lv_count + 1.
CONDENSE fc-fieldname.
WRITE:/ 'Field', fc-fieldname, 'value',,'not in table ', fc-checktable.
ENDIF.
ENDIF.
ENDIF.
IFIS ASSIGNED.
UNASSIGN.
ENDIF.
IFIS ASSIGNED.
UNASSIGN.
ENDIF.
ENDLOOP.
IF lv_count = 0.
MODIFY (tabname) FROM.
ELSEIF lv_count <> 0.
lv_count = 0.
WRITE:/ 'Above mentioned errors in this record: ', gv_rec_proc.
LOOP AT lt_dfies INTO ls_dfies.
ASSIGN COMPONENT ls_dfies-fieldname OF STRUCTURETO .
WRITE:.
ENDLOOP.
SKIP.
DELETE.
gv_rec_nonp = gv_rec_nonp + 1.
lv_error = ''.
ENDIF.
ELSE.
WRITE:/ 'Already Exists,Non Key Fields Updated: ', gv_rec_proc.
LOOP AT lt_dfies INTO ls_dfies.
ASSIGN COMPONENT ls_dfies-fieldname OF STRUCTURETO .
WRITE:.
ENDLOOP.
gv_rec_dupl = gv_rec_dupl + 1.
MODIFY (tabname) FROM.
ENDIF.
ENDIF.
ENDLOOP.
ENDIF.
ENDIF.
ENDFORM. " update_table_from_file.
*&---------------------------------------------------------------------*
*& Form delete_table
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM delete_table .
DATA: l_answer TYPE c.
CALL FUNCTION 'POPUP_TO_CONFIRM'
EXPORTING
titlebar = tabname
text_question = 'All entries in the table will be deleted !!!'
default_button = '2'
display_cancel_button = ''
IMPORTING
answer = l_answer
EXCEPTIONS
OTHERS = 1.
IF l_answer = '1'.
IF NOT[] IS INITIAL.
DELETE (tabname) FROM TABLE.
ENDIF.
ELSE.
REFRESH.
ENDIF.
ENDFORM. " delete_table
*&---------------------------------------------------------------------*
*& Form drill_down
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->INDEX text
* -->COLUMN text
*----------------------------------------------------------------------*
FORM drill_down USING index column.
ENDFORM. " drill_down
*&---------------------------------------------------------------------*
*& Form transfer_to_dyntab
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->itab text
*----------------------------------------------------------------------*
FORM transfer_to_dyntab.
DATA lt_type TYPE truxs_t_text_data.
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
i_tab_raw_data = lt_type
i_filename = gv_file
i_line_header = 'X'
TABLES
i_tab_converted_data =
EXCEPTIONS
conversion_failed = 1
OTHERS = 2.
ENDFORM. " transfer_to_dyntab
*&---------------------------------------------------------------------*
*& Form mydyntable
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->LT text
*----------------------------------------------------------------------*
FORM mydyntable USING lt TYPE lvc_t_fcat.
*-------------- Create Dyn Table From FC
FIELD-SYMBOLS:TYPE REF TO data.
FIELD-SYMBOLS:TYPE STANDARD TABLE.
FIELD-SYMBOLS:TYPE REF TO data.
FIELD-SYMBOLS:TYPE STANDARD TABLE.
FIELD-SYMBOLS:TYPE REF TO data.
FIELD-SYMBOLS:TYPE STANDARD TABLE.
*------------- Create Reoprting Table
DATA: lt_data TYPE REF TO data.
ASSIGN lt_data TO.
IFIS ASSIGNED.
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = lt
IMPORTING
ep_table =
EXCEPTIONS
generate_subpool_dir_full = 1
OTHERS = 2.
ASSIGN->* TO .
IFIS ASSIGNED.
ASSIGNTO .
ENDIF.
ENDIF.
*------------ Create Deletion Table
DATA: lt_tmp TYPE REF TO data.
ASSIGN lt_tmp TO.
IFIS ASSIGNED.
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = lt
IMPORTING
ep_table =
EXCEPTIONS
generate_subpool_dir_full = 1
OTHERS = 2.
ASSIGN->* TO .
IFIS ASSIGNED.
ASSIGNTO .
ENDIF.
ENDIF.
*------------ Create Master Table
DATA: lt_xh TYPE REF TO data.
ASSIGN lt_xh TO.
IFIS ASSIGNED.
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = lt
IMPORTING
ep_table =
EXCEPTIONS
generate_subpool_dir_full = 1
OTHERS = 2.
ASSIGN->* TO .
IFIS ASSIGNED.
ASSIGNTO .
ENDIF.
ENDIF.
ENDFORM. "MYDYNTABLE
FUNCTION zbc_free_table_selections.
*"----------------------------------------------------------------------
*"*"Local Interface:
*" IMPORTING
*" VALUE(TABNAME) LIKE DD02L-TABNAME OPTIONAL
*" REFERENCE(TREE) DEFAULT SPACE
*" EXPORTING
*" REFERENCE(DS_CLAUSES) TYPE RSDS_WHERE
*" EXCEPTIONS
*" TABLE_NOT_VALID
*" OTHER_ERROR
*"----------------------------------------------------------------------
STATICS: lv_init(1).
STATICS: lv_tabname LIKE dd02l-tabname.
STATICS texpr TYPE rsds_texpr.
STATICS twhere TYPE rsds_twhere.
STATICS trange TYPE rsds_trange.
DATA BEGIN OF qcat. "Selections View for
INCLUDE STRUCTURE rsdsqcat. "Free Selectoptions
DATA END OF qcat.
DATA BEGIN OF tabs OCCURS 10.
INCLUDE STRUCTURE rsdstabs.
DATA END OF tabs.
DATA BEGIN OF fields OCCURS 10.
INCLUDE STRUCTURE rsdsfields.
DATA END OF fields.
DATA BEGIN OF efields OCCURS 10.
INCLUDE STRUCTURE rsdsfields.
DATA END OF efields.
STATICS selid LIKE rsdynsel-selid.
STATICS actnum LIKE sy-tfill.
DATA title LIKE sy-title VALUE 'Selection Screen'.
DATA: maxnum LIKE sy-subrc VALUE '69'.
CLEAR tabs.
tabs-prim_tab = tabname.
COLLECT tabs.
DATA: position LIKE dd03l-position.
DATA: keyflag LIKE dd03l-keyflag.
CLEAR fields.
fields-tablename = tabname.
fields-sign = 'I'.
DATA: step LIKE sy-subrc.
IF lv_init <> 'X' AND lv_tabname <> tabname.
lv_tabname = tabname.
SELECT fieldname keyflag position
INTO (fields-fieldname, keyflag, position)
FROM dd03l
WHERE tabname = tabname
AND fieldname NOT LIKE '.INCLU%'
AND datatype NE 'CLNT'
ORDER BY position.
ADD 1 TO step.
CHECK step LE maxnum.
IF keyflag <> 'X'.
efields = fields.
APPEND efields.
ENDIF.
APPEND fields.
ENDSELECT.
IF sy-subrc <> 0.
RAISE table_not_valid.
ENDIF.
CALL FUNCTION 'FREE_SELECTIONS_INIT'
EXPORTING
expressions = texpr
kind = 'T'
IMPORTING
selection_id = selid
expressions = texpr
where_clauses = twhere
field_ranges = trange
number_of_active_fields = actnum
TABLES
tables_tab = tabs
fields_tab = fields
fields_not_selected = efields
EXCEPTIONS
fields_incomplete = 01
fields_no_join = 02
field_not_found = 03
no_tables = 04
table_not_found = 05
expression_not_supported = 06
incorrect_expression = 07
illegal_kind = 08
area_not_found = 09
inconsistent_area = 10
kind_f_no_fields_left = 11
kind_f_no_fields = 12
too_many_fields = 13.
lv_init = 'X'.
ENDIF.
IF NOT lv_init IS INITIAL.
CALL FUNCTION 'FREE_SELECTIONS_DIALOG'
EXPORTING
selection_id = selid
title = title
TREE_VISIBLE = tree
IMPORTING
where_clauses = twhere
expressions = texpr
field_ranges = trange
number_of_active_fields = actnum
TABLES
fields_tab = fields
EXCEPTIONS
internal_error = 01
no_action = 02
no_fields_selected = 03
no_tables_selected = 04
selid_not_found = 05.
IF sy-subrc = 0.
CLEAR ds_clauses.
MOVE tabname TO ds_clauses-tablename.
READ TABLE twhere WITH KEY ds_clauses-tablename INTO ds_clauses.
IF sy-subrc <> 0.
RAISE other_error.
ENDIF.
ELSE.
RAISE other_error.
ENDIF.
ELSE.
RAISE other_error.
ENDIF.
ENDFUNCTION.
TABLES: sscrfields, "Fields on selection screens
dd01l,
dd02l,
dd03l,
dd03vt,
zbc_excepload.
TYPE-POOLS: rsds, truxs.
DATA ds_clauses TYPE rsds_where.
DATA: BEGIN OF ds_where OCCURS 0,
line(72),
END OF ds_where.
DATA: text TYPE string.
DATA: sl_index LIKE sy-tabix.
DATA: lt_exclude TYPE ui_functions.
DATA: lt_dd03l LIKE dd03l OCCURS 0 WITH HEADER LINE.
DATA: num TYPE i,
max_len TYPE i,
check_len TYPE i,
sl_sel TYPE c.
DATA: gv_file LIKE rlgrap-filename,
gv_rec_read TYPE i,
gv_rec_proc TYPE i,
gv_rec_load TYPE i,
gv_rec_dele TYPE i,
gv_rec_dupl TYPE i,
gv_rec_chan TYPE i,
gv_rec_nonp TYPE i.
DATA: lt_dfies TYPE ddfields,
ls_dfies TYPE dfies.
FIELD-SYMBOLS:
***********************************************************************
* CLASS cl_event_receiver DEFINITION
***********************************************************************
CLASS cl_event_receiver DEFINITION.
PUBLIC SECTION.
METHODS:
handle_user_command
FOR EVENT user_command OF cl_gui_alv_grid
IMPORTING e_ucomm,
handle_toolbar
FOR EVENT toolbar OF cl_gui_alv_grid
IMPORTING e_object,
handle_double_click
FOR EVENT double_click OF cl_gui_alv_grid
IMPORTING e_row e_column.
PRIVATE SECTION.
ENDCLASS. "CL_EVENT_RECEIVER DEFINITION
*----------------------------------------------------------------------*
* CLASS cl_event_receiver IMPLEMENTATION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS cl_event_receiver IMPLEMENTATION.
METHOD handle_double_click.
PERFORM drill_down USING e_row-index e_column.
ENDMETHOD. "handle_double_click
METHOD handle_toolbar.
PERFORM handle_toolbar USING e_object.
ENDMETHOD. "handle_toolbar
METHOD handle_user_command.
CASE e_ucomm.
WHEN 'CCCP'.
PERFORM update_table.
ENDCASE.
ENDMETHOD. "handle_user_command
ENDCLASS. "CL_EVENT_RECEIVER IMPLEMENTATION
DATA: event_receiver TYPE REF TO cl_event_receiver.
DATA: alv_grid TYPE REF TO cl_gui_alv_grid.
DATA: alv_container TYPE REF TO cl_gui_custom_container.
DATA: fieldcat TYPE lvc_t_fcat.
DATA: layout TYPE lvc_s_layo.
DATA: fc TYPE lvc_s_fcat.
DATA: gs_variant TYPE disvariant,
gt_top_of_page TYPE slis_t_listheader.
DATA: lt_cells TYPE lvc_t_moce.
DATA: l_ans(1).
DATA: tabnameh TYPE dd02l-tabname.
TYPE-POOLS: icon.
FIELD-SYMBOLS:
FIELD-SYMBOLS:
FIELD-SYMBOLS:
FIELD-SYMBOLS:
FIELD-SYMBOLS:
FIELD-SYMBOLS:
DEFINE show_alv.
*--- &1, Container
*--- &2, Container ID
*--- &3, ALV Layout
*--- &4, ALV Display Variant
*--- &5, Table to display in ALV
*--- &6, ALV Field Catalouge
*--- &7, ALV Grid ID
*--- Create Object Container
if &1 is initial.
create object &1
exporting
container_name = &2.
*--- Create Object ALV Grid assigning container
create object &7
exporting
i_parent = &1.
*--- Create Event Receiver
create object event_receiver.
*--- Assign methods for event handling
set handler event_receiver->handle_toolbar for &7.
set handler event_receiver->handle_user_command for &7.
set handler event_receiver->handle_double_click for &7.
*--- Exclude toolbar buttons
perform exclude_tb_functions changing lt_exclude.
*--- Display ALV Grid Report
call method &7->set_table_for_first_display
exporting
is_layout = &3
is_variant = &4
i_save = 'A'
it_toolbar_excluding = lt_exclude
changing
it_outtab = &5
it_fieldcatalog = &6.
call method &7->set_ready_for_input
exporting
i_ready_for_input = 0.
else.
set handler event_receiver->handle_toolbar for &7.
call method &7->refresh_table_display.
endif.
*--- Set focus to the active ALV Grid
call method &7->set_toolbar_interactive.
call method cl_gui_control=>set_focus
exporting
control = &7.
END-OF-DEFINITION.
*----------------------------------------------------------------*
* SELECTION-SCREEN.
*----------------------------------------------------------------*
SELECTION-SCREEN BEGIN OF BLOCK block_1 WITH FRAME.
SELECTION-SCREEN BEGIN OF LINE.
* text-012 - 'Table Name'
SELECTION-SCREEN COMMENT 1(33) text-012.
PARAMETERS: tabname LIKE dd02l-tabname DEFAULT 'Z'.
* text-003 - 'Selection'
SELECTION-SCREEN: PUSHBUTTON 70(20) selopt USER-COMMAND sta1.
SELECTION-SCREEN END OF LINE.
* numrows(text) - 'Max Number of ROWS'
PARAMETERS: numrows LIKE sy-subrc.
PARAMETERS: xoutput LIKE layout-frontend DEFAULT 'G'.
PARAMETERS: upload AS CHECKBOX DEFAULT ''.
SELECTION-SCREEN END OF BLOCK block_1.
************************************************************************
* At Selection-Screen *
************************************************************************
AT SELECTION-SCREEN.
SELECT SINGLE tabname
INTO tabname
FROM dd02l
WHERE tabname = tabname
AND as4local = 'A'
AND ( tabclass = 'TRANSP' OR tabclass = 'POOL'
OR tabclass = 'CLUSTER' ).
IF sy-subrc <> 0.
MESSAGE 'Table is not valid' TYPE 'S'.
RETURN.
ENDIF.
SELECT SINGLE * FROM zbc_excepload WHERE tabname = tabname.
IF sy-subrc <> 0.
IF tabname+0(1) <> 'Z' AND tabname+0(1) <> 'Y'.
MESSAGE 'This utility is meant for only customer name space Z* and Y*' TYPE 'E'.
RETURN.
ENDIF.
ENDIF.
CASE sscrfields-ucomm.
WHEN 'STA1'.
CLEAR sl_sel.
CALL FUNCTION 'ZBC_FREE_TABLE_SELECTIONS'
EXPORTING
tabname = tabname
IMPORTING
ds_clauses = ds_clauses
EXCEPTIONS
table_not_valid = 1
other_error = 2
OTHERS = 3.
IF sy-subrc = 0.
sl_sel = 'X'.
ENDIF.
ENDCASE.
*----------------------------------------------------------------*
* INITIALIZATION.
*----------------------------------------------------------------*
INITIALIZATION.
MOVE ' (4G) Filter records' TO selopt.
*----------------------------------------------------------------*
* START-OF-SELECTION.
*----------------------------------------------------------------*
START-OF-SELECTION.
FIELD-SYMBOLS:
CONDENSE tabname.
SELECT SINGLE tabname
INTO tabname
FROM dd02l
WHERE tabname = tabname
AND as4local = 'A'
AND ( tabclass = 'TRANSP' OR tabclass = 'POOL'
OR tabclass = 'CLUSTER' ).
IF sy-subrc <> 0.
MESSAGE 'Table is not valid' TYPE 'S'.
RETURN.
ENDIF.
PERFORM alv_set_layout. "Define ALV Layout
PERFORM alv_set_fieldcat. "Create ALV field catalogue for initial display
PERFORM mydyntable USING fieldcat. "Create Dynamic tables based on DB table name to be updated
IF
CALL FUNCTION 'DDIF_FIELDINFO_GET'
EXPORTING
tabname = tabname
TABLES
dfies_tab = lt_dfies
EXCEPTIONS
not_found = 1
internal_error = 2
OTHERS = 3.
ENDIF.
IF upload = 'X'.
CALL FUNCTION 'POPUP_TO_DECIDE'
EXPORTING
defaultoption = 'A'
textline1 = text-o01
textline2 = text-o02
textline3 = text-o03
text_option1 = text-o07
text_option2 = text-o08
titel = text-o10
start_column = 25
start_row = 6
cancel_display = 'X'
IMPORTING
answer = l_ans.
ELSE.
IF sl_sel = 'X'.
SELECT *
FROM (tabname)
INTO CORRESPONDING FIELDS OF TABLE
WHERE (ds_clauses-where_tab).
ELSE.
SELECT *
FROM (tabname)
INTO CORRESPONDING FIELDS OF TABLE
ENDIF.
ENDIF.
CASE l_ans.
WHEN '1'.
AUTHORITY-CHECK OBJECT 'ZRDM000001'
ID 'ACTION' FIELD 'A'.
IF sy-subrc = 0.
AUTHORITY-CHECK OBJECT 'ZRDM000001'
ID 'ACTION' FIELD 'C'.
IF sy-subrc = 0.
* Locating the file path and filename on the selection screen
CALL FUNCTION 'F4_FILENAME'
EXPORTING
program_name = syst-cprog
dynpro_number = syst-dynnr
IMPORTING
file_name = gv_file.
PERFORM update_table_from_file.
ELSE.
MESSAGE e004(zrp).
* No Authorisation to Create/Change...
ENDIF.
ELSE.
MESSAGE e004(zrp).
* No Authorisation to Create/Change...
ENDIF.
WHEN '2'.
AUTHORITY-CHECK OBJECT 'ZRDM000001'
ID 'ACTION' FIELD 'A'
ID 'ACTION' FIELD 'C'.
IF sy-subrc = 0.
* Locating the file path and filename on the selection screen
CALL FUNCTION 'F4_FILENAME'
EXPORTING
program_name = syst-cprog
dynpro_number = syst-dynnr
IMPORTING
file_name = gv_file.
SELECT *
FROM (tabname)
INTO CORRESPONDING FIELDS OF TABLE
AUTHORITY-CHECK OBJECT 'ZRDM000001'
ID 'ACTION' FIELD 'E'.
IF sy-subrc = 0.
PERFORM delete_table.
PERFORM update_table_from_file.
ELSE.
MESSAGE e005(zrp).
* No Authorisation to Delete...
ENDIF.
ELSE.
MESSAGE e004(zrp).
* No Authorisation to Create/Change...
ENDIF.
WHEN 'A'.
WHEN OTHERS.
CALL SCREEN 100.
ENDCASE.
IF
UNASSIGN
ENDIF.
IF upload = 'X'.
WRITE:/ 'Records read from File : ', gv_rec_read.
WRITE:/ 'Records processed : ', gv_rec_proc.
WRITE:/ 'Records with errors : ', gv_rec_nonp.
ENDIF.
IF gv_rec_proc <> 0..
WRITE:/ 'Duplicates Processed : ', gv_rec_dupl.
DESCRIBE TABLE
WRITE:/ 'Records deleted : ', gv_rec_dele.
DESCRIBE TABLE
WRITE:/ 'Records updated / inserted: ', gv_rec_load.
WRITE:/ 'Details of records deleted as below:'.
LOOP AT
WRITE:/'Deleted'.
LOOP AT lt_dfies INTO ls_dfies.
ASSIGN COMPONENT ls_dfies-fieldname OF STRUCTURE
*
WRITE:
ENDLOOP.
ENDLOOP.
WRITE:/ 'Details of records Updated / Inserted: '.
LOOP AT
WRITE:/ 'Updated / Inserted'.
LOOP AT lt_dfies INTO ls_dfies.
ASSIGN COMPONENT ls_dfies-fieldname OF STRUCTURE
WRITE:
ENDLOOP.
ENDLOOP.
ENDIF.
*&---------------------------------------------------------------------*
*& Module STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE status_0100 OUTPUT.
* Standard list status with 'SAVE' button
SET PF-STATUS 'STLI'.
gs_variant-report = sy-repid.
gs_variant-handle = space.
gs_variant-log_group = space.
gs_variant-username = space.
gs_variant-text = space.
gs_variant-dependvars = space.
show_alv alv_container 'ALV_CONTAINER' layout gs_variant
ENDMODULE. " STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_0100 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE user_command_0100 INPUT.
CASE sy-ucomm.
WHEN 'EDIT'.
AUTHORITY-CHECK OBJECT 'ZRDM000001'
ID 'ACTION' FIELD 'A'
ID 'ACTION' FIELD 'C'
ID 'ACTION' FIELD 'E'.
IF sy-subrc = 0.
CALL METHOD alv_grid->set_ready_for_input
EXPORTING
i_ready_for_input = 1.
ELSE.
MESSAGE e004(zrp).
* No Authorisation to Create/Change...
CALL METHOD alv_grid->set_ready_for_input
EXPORTING
i_ready_for_input = 0.
ENDIF.
WHEN 'DISP'.
CALL METHOD alv_grid->set_ready_for_input
EXPORTING
i_ready_for_input = 0.
WHEN '%EX' OR 'BACK'.
CALL METHOD alv_container->free.
CLEAR: alv_container.
FREE : alv_container.
SET SCREEN 0.
LEAVE SCREEN.
WHEN 'RW'.
CALL METHOD alv_container->free.
CLEAR: alv_container.
FREE : alv_container.
LEAVE PROGRAM.
WHEN OTHERS.
ENDCASE.
ENDMODULE. " USER_COMMAND_0100 INPUT
*&---------------------------------------------------------------------*
*& Form alv_set_layout
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM alv_set_layout.
*... Display options
layout-zebra = 'X'.
layout-excp_conds = 'X'.
layout-cwidth_opt = ''.
layout-frontend = xoutput.
ENDFORM. "alv_set_layout
*&---------------------------------------------------------------------*
*& Form alv_set_fieldcat
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM alv_set_fieldcat .
REFRESH: fieldcat.
DATA: v_text(40), lv_index LIKE sy-index.
DATA: v_h1(40),v_h2(40),v_h3(40),v_h4(40),v_h5(40).
FIELD-SYMBOLS:
ASSIGN tabname TO
IF
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
i_buffer_active = ''
i_structure_name =
i_client_never_display = ''
CHANGING
ct_fieldcat = fieldcat
EXCEPTIONS
inconsistent_interface = 1
program_error = 2.
UNASSIGN
LOOP AT fieldcat INTO fc.
SELECT SINGLE * FROM dd03vt
WHERE tabname = tabname AND fieldname = fc-fieldname
AND ddlanguage = sy-langu.
fc-rollname = dd03vt-rollname.
fc-checktable = dd03vt-checktable.
IF fc-key = 'X'.
CONCATENATE '*' dd03vt-scrtext_s INTO fc-scrtext_s SEPARATED BY space.
CONCATENATE '*' dd03vt-scrtext_m INTO fc-scrtext_m SEPARATED BY space.
CONCATENATE '*' dd03vt-scrtext_l INTO fc-scrtext_l SEPARATED BY space.
CONCATENATE '*' dd03vt-reptext INTO fc-reptext SEPARATED BY space.
CONCATENATE '*' dd03vt-reptext INTO fc-seltext SEPARATED BY space.
MOVE dd03vt-scrtext_l TO fc-tooltip.
ELSE.
MOVE: dd03vt-scrtext_s TO fc-scrtext_s,
dd03vt-scrtext_m TO fc-scrtext_m,
dd03vt-scrtext_l TO fc-scrtext_l,
dd03vt-reptext TO fc-reptext,
dd03vt-reptext TO fc-seltext,
dd03vt-scrtext_l TO fc-tooltip.
ENDIF.
IF fc-checktable IS INITIAL OR fc-checktable = '*'.
SELECT SINGLE entitytab INTO fc-checktable FROM dd01l WHERE domname = fc-domname.
ENDIF.
IF fc-fieldname <> 'MANDT'.
fc-edit = 'X'.
ENDIF.
MODIFY fieldcat FROM fc.
ENDLOOP.
ENDIF.
ENDFORM. " alv_set_fieldcat
*&---------------------------------------------------------------------*
*& Form exclude_tb_functions
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->PT_EXCLUDE text
*----------------------------------------------------------------------*
FORM exclude_tb_functions CHANGING pt_exclude TYPE ui_functions.
DATA ls_exclude TYPE ui_func.
ls_exclude = cl_gui_alv_grid=>mc_fc_check.
APPEND ls_exclude TO pt_exclude.
ls_exclude = cl_gui_alv_grid=>mc_fc_help.
APPEND ls_exclude TO pt_exclude.
ls_exclude = cl_gui_alv_grid=>mc_fc_detail.
APPEND ls_exclude TO pt_exclude.
ls_exclude = cl_gui_alv_grid=>mc_fc_sum.
APPEND ls_exclude TO pt_exclude.
ls_exclude = cl_gui_alv_grid=>mc_fc_subtot.
APPEND ls_exclude TO pt_exclude.
ls_exclude = cl_gui_alv_grid=>mc_fc_info.
APPEND ls_exclude TO pt_exclude.
ENDFORM. "EXCLUDE_TB_FUNCTIONS
*&---------------------------------------------------------------------*
*& Form handle_toolbar
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->I_OBJECT text
*----------------------------------------------------------------------*
FORM handle_toolbar USING i_object TYPE REF TO cl_alv_event_toolbar_set .
*--- This code adds the Pushbutton for comparison to the ALV Grid toolbar
DATA: ls_toolbar TYPE stb_button.
CLEAR ls_toolbar.
MOVE 3 TO ls_toolbar-butn_type.
APPEND ls_toolbar TO i_object->mt_toolbar.
CLEAR ls_toolbar.
MOVE 0 TO ls_toolbar-butn_type.
MOVE 'CCCP' TO ls_toolbar-function. "#EC NOTEXT
MOVE icon_system_save TO ls_toolbar-icon.
MOVE 'Save Changed Data'(201) TO ls_toolbar-quickinfo.
IF sy-ucomm = 'EDIT'.
MOVE ' ' TO ls_toolbar-disabled. "#EC NOTEXT
ELSE.
MOVE 'X' TO ls_toolbar-disabled. "#EC NOTEXT
ENDIF.
APPEND ls_toolbar TO i_object->mt_toolbar.
ENDFORM . "handle_toolbar
*&---------------------------------------------------------------------*
*& Form update_table
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text *----------------------------------------------------------------------* FORM update_table . DATA: l_answer TYPE c. DATA: l_tabix LIKE sy-tabix. FIELD-SYMBOLS:
DATA: lv_answer TYPE c.
DATA: lv_error TYPE c.
DATA: lv_count TYPE i.
DATA: lv_fld(255) TYPE c.
CALL FUNCTION 'POPUP_TO_CONFIRM'
EXPORTING
titlebar = tabname
text_question = 'Update table?'
default_button = '2'
display_cancel_button = ' '
IMPORTING
answer = l_answer
EXCEPTIONS
OTHERS = 1.
IF l_answer = '1'.
*---- Delete all common records from
*---- Now
*---- Now
LOOP AT
IF
LOOP AT
l_tabix = sy-tabix.
IF
IF
DELETE
ENDIF.
ENDIF.
ENDLOOP.
ENDIF.
ENDLOOP.
*--- Delete Records marked for deletion & Change
IF NOT
DELETE (tabname) FROM TABLE
ENDIF.
*--- Update Records Marked for change or creation
IF NOT
LOOP AT
gv_rec_proc = gv_rec_proc + 1.
REFRESH ds_where.
LOOP AT fieldcat INTO fc WHERE key = 'X' AND fieldname <> 'MANDT'.
ASSIGN COMPONENT fc-fieldname OF STRUCTURE
CONDENSE:
CLEAR: lv_fld.
CONCATENATE `'`
IF sy-tabix = 2.
CONCATENATE ' ( ' fc-fieldname 'EQ' lv_fld ' )' INTO ds_where-line SEPARATED BY space.
APPEND ds_where.
ELSEIF sy-tabix > 2.
CONCATENATE 'AND' '( ' fc-fieldname 'EQ' lv_fld ' )' INTO ds_where-line SEPARATED BY space.
APPEND ds_where.
ENDIF.
ENDLOOP.
ds_where-line = '.'.
APPEND ds_where.
IF
SELECT *
FROM (tabname)
INTO CORRESPONDING FIELDS OF TABLE
IF sy-subrc <> 0.
LOOP AT fieldcat INTO fc WHERE checktable <> ''.
lv_error = 'X'.
FIELD-SYMBOLS:
DATA: dref_table_line TYPE REF TO data.
CREATE DATA dref_table_line TYPE (fc-checktable).
ASSIGN dref_table_line->* TO
IF
REFRESH: ds_where.
ASSIGN COMPONENT fc-fieldname OF STRUCTURE
CLEAR: lv_fld.
IF
SELECT * FROM dd03l WHERE tabname = fc-checktable AND rollname = fc-rollname
AND domname = fc-domname.
REFRESH: ds_where.
IF fc-checktable <> tabname.
CONCATENATE `'`
CONCATENATE '( ' dd03l-fieldname 'EQ' lv_fld ' ).' INTO ds_where-line SEPARATED BY space.
APPEND ds_where.
IF
IF NOT ds_where[] IS INITIAL.
SELECT SINGLE * INTO CORRESPONDING FIELDS OF
IF sy-subrc = 0.
lv_error = ' '.
EXIT.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ENDSELECT.
IF sy-subrc <> 0 AND fc-checktable <> tabname AND lv_error = 'X'.
SELECT * FROM dd03l WHERE tabname = fc-checktable AND domname = fc-domname.
REFRESH: ds_where.
IF sy-subrc = 0 AND fc-checktable <> tabname.
CONCATENATE `'`
CONCATENATE '( ' dd03l-fieldname 'EQ' lv_fld ' ).' INTO ds_where-line SEPARATED BY space.
APPEND ds_where.
IF
IF NOT ds_where[] IS INITIAL.
SELECT SINGLE * INTO CORRESPONDING FIELDS OF
IF sy-subrc = 0.
lv_error = ' '.
EXIT.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ENDSELECT.
ENDIF.
IF lv_error = 'X' AND fc-checktable <> tabname.
lv_count = lv_count + 1.
CONDENSE fc-fieldname.
WRITE:/ 'Field', fc-fieldname, 'value',
ENDIF.
ENDIF.
ENDIF.
IF
UNASSIGN
ENDIF.
IF
UNASSIGN
ENDIF.
ENDLOOP.
IF lv_count = 0.
MODIFY (tabname) FROM
ELSEIF lv_count <> 0.
lv_count = 0.
WRITE:/ 'Above mentioned errors in this record: ', gv_rec_proc.
LOOP AT lt_dfies INTO ls_dfies.
ASSIGN COMPONENT ls_dfies-fieldname OF STRUCTURE
WRITE:
ENDLOOP.
SKIP.
DELETE
gv_rec_nonp = gv_rec_nonp + 1.
lv_error = ''.
ENDIF.
ELSE.
WRITE:/ 'Already Exists,Non Key Fields Updated: ', gv_rec_proc.
LOOP AT lt_dfies INTO ls_dfies.
ASSIGN COMPONENT ls_dfies-fieldname OF STRUCTURE
WRITE:
ENDLOOP.
gv_rec_dupl = gv_rec_dupl + 1.
MODIFY (tabname) FROM
ENDIF.
ENDIF.
ENDLOOP.
ENDIF.
ENDIF.
COMMIT WORK AND WAIT.
ENDFORM. " update_table
*&---------------------------------------------------------------------*
*& Form update_table_from_file
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM update_table_from_file.
FIELD-SYMBOLS:
DATA: lv_answer TYPE c.
DATA: lv_error TYPE c.
DATA: lv_count TYPE i.
DATA: lv_fld(255) TYPE c.
DATA: lv_file TYPE string.
DATA: lv_string(1023).
CALL FUNCTION 'POPUP_TO_CONFIRM'
EXPORTING
titlebar = tabname
text_question = 'Update table based on file ?'
default_button = '2'
display_cancel_button = ' '
IMPORTING
answer = lv_answer
EXCEPTIONS
OTHERS = 1.
IF lv_answer = '1'.
CALL FUNCTION 'POPUP_TO_DECIDE'
EXPORTING
defaultoption = 'A'
textline1 = 'Select type of'
textline2 = 'file to be used'
text_option1 = 'Tab Delimited'
text_option2 = 'Excel Sheet'
icon_text_option1 = 'ICON_WD_TEXT_EDIT'
icon_text_option2 = 'ICON_LIST'
start_column = 25
start_row = 6
cancel_display = ''
titel = 'Option'
IMPORTING
answer = lv_answer.
CASE lv_answer.
WHEN '1'.
MOVE gv_file TO lv_file.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = lv_file
filetype = 'ASC'
has_field_separator = 'X'
read_by_line = 'X'
TABLES
data_tab =
EXCEPTIONS
file_open_error = 1
file_read_error = 2
no_batch = 3
gui_refuse_filetransfer = 4
invalid_type = 5
no_authority = 6
unknown_error = 7
bad_data_format = 8
header_not_allowed = 9
separator_not_allowed = 10
header_too_long = 11
unknown_dp_error = 12
access_denied = 13
dp_out_of_memory = 14
disk_full = 15
dp_timeout = 16.
WHEN '2'.
PERFORM transfer_to_dyntab.
WHEN OTHERS.
ENDCASE.
IF NOT
DESCRIBE TABLE
LOOP AT
gv_rec_proc = gv_rec_proc + 1.
REFRESH ds_where.
LOOP AT fieldcat INTO fc WHERE key = 'X' AND fieldname <> 'MANDT'.
ASSIGN COMPONENT fc-fieldname OF STRUCTURE
CONDENSE:
CLEAR: lv_fld.
CONCATENATE `'`
IF sy-tabix = 2.
CONCATENATE ' ( ' fc-fieldname 'EQ' lv_fld ' )' INTO ds_where-line SEPARATED BY space.
APPEND ds_where.
ELSEIF sy-tabix > 2.
CONCATENATE 'AND' '( ' fc-fieldname 'EQ' lv_fld ' )' INTO ds_where-line SEPARATED BY space.
APPEND ds_where.
ENDIF.
ENDLOOP.
ds_where-line = '.'.
APPEND ds_where.
IF
SELECT *
FROM (tabname)
INTO CORRESPONDING FIELDS OF TABLE
IF sy-subrc <> 0.
LOOP AT fieldcat INTO fc WHERE checktable <> ''.
lv_error = 'X'.
FIELD-SYMBOLS:
DATA: dref_table_line TYPE REF TO data.
CREATE DATA dref_table_line TYPE (fc-checktable).
ASSIGN dref_table_line->* TO
IF
ASSIGN COMPONENT fc-fieldname OF STRUCTURE
CLEAR: lv_fld.
IF
SELECT * FROM dd03l WHERE tabname = fc-checktable AND rollname = fc-rollname
AND domname = fc-domname.
IF fc-checktable <> tabname.
REFRESH: ds_where.
CONCATENATE `'`
CONCATENATE '( ' dd03l-fieldname 'EQ' lv_fld ' ).' INTO ds_where-line SEPARATED BY space.
APPEND ds_where.
IF
IF NOT ds_where[] IS INITIAL.
SELECT SINGLE * INTO CORRESPONDING FIELDS OF
IF sy-subrc = 0.
lv_error = ' '.
EXIT.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ENDSELECT.
IF sy-subrc <> 0 AND fc-checktable <> tabname AND lv_error = 'X'.
SELECT * FROM dd03l WHERE tabname = fc-checktable AND domname = fc-domname.
IF sy-subrc = 0 AND fc-checktable <> tabname.
REFRESH: ds_where.
CONCATENATE `'`
CONCATENATE '( ' dd03l-fieldname 'EQ' lv_fld ' ).' INTO ds_where-line SEPARATED BY space.
APPEND ds_where.
IF
IF NOT ds_where[] IS INITIAL.
SELECT SINGLE * INTO CORRESPONDING FIELDS OF
IF sy-subrc = 0.
lv_error = ' '.
EXIT.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ENDSELECT.
ENDIF.
IF lv_error = 'X' AND fc-checktable <> tabname.
lv_count = lv_count + 1.
CONDENSE fc-fieldname.
WRITE:/ 'Field', fc-fieldname, 'value',
ENDIF.
ENDIF.
ENDIF.
IF
UNASSIGN
ENDIF.
IF
UNASSIGN
ENDIF.
ENDLOOP.
IF lv_count = 0.
MODIFY (tabname) FROM
ELSEIF lv_count <> 0.
lv_count = 0.
WRITE:/ 'Above mentioned errors in this record: ', gv_rec_proc.
LOOP AT lt_dfies INTO ls_dfies.
ASSIGN COMPONENT ls_dfies-fieldname OF STRUCTURE
WRITE:
ENDLOOP.
SKIP.
DELETE
gv_rec_nonp = gv_rec_nonp + 1.
lv_error = ''.
ENDIF.
ELSE.
WRITE:/ 'Already Exists,Non Key Fields Updated: ', gv_rec_proc.
LOOP AT lt_dfies INTO ls_dfies.
ASSIGN COMPONENT ls_dfies-fieldname OF STRUCTURE
WRITE:
ENDLOOP.
gv_rec_dupl = gv_rec_dupl + 1.
MODIFY (tabname) FROM
ENDIF.
ENDIF.
ENDLOOP.
ENDIF.
ENDIF.
ENDFORM. " update_table_from_file.
*&---------------------------------------------------------------------*
*& Form delete_table
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM delete_table .
DATA: l_answer TYPE c.
CALL FUNCTION 'POPUP_TO_CONFIRM'
EXPORTING
titlebar = tabname
text_question = 'All entries in the table will be deleted !!!'
default_button = '2'
display_cancel_button = ''
IMPORTING
answer = l_answer
EXCEPTIONS
OTHERS = 1.
IF l_answer = '1'.
IF NOT
DELETE (tabname) FROM TABLE
ENDIF.
ELSE.
REFRESH
ENDIF.
ENDFORM. " delete_table
*&---------------------------------------------------------------------*
*& Form drill_down
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->INDEX text
* -->COLUMN text
*----------------------------------------------------------------------*
FORM drill_down USING index column.
ENDFORM. " drill_down
*&---------------------------------------------------------------------*
*& Form transfer_to_dyntab
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->itab text
*----------------------------------------------------------------------*
FORM transfer_to_dyntab.
DATA lt_type TYPE truxs_t_text_data.
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
i_tab_raw_data = lt_type
i_filename = gv_file
i_line_header = 'X'
TABLES
i_tab_converted_data =
EXCEPTIONS
conversion_failed = 1
OTHERS = 2.
ENDFORM. " transfer_to_dyntab
*&---------------------------------------------------------------------*
*& Form mydyntable
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->LT text
*----------------------------------------------------------------------*
FORM mydyntable USING lt TYPE lvc_t_fcat.
*-------------- Create Dyn Table From FC
FIELD-SYMBOLS:
FIELD-SYMBOLS:
FIELD-SYMBOLS:
FIELD-SYMBOLS:
FIELD-SYMBOLS:
FIELD-SYMBOLS:
*------------- Create Reoprting Table
DATA: lt_data TYPE REF TO data.
ASSIGN lt_data TO
IF
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = lt
IMPORTING
ep_table =
EXCEPTIONS
generate_subpool_dir_full = 1
OTHERS = 2.
ASSIGN
IF
ASSIGN
ENDIF.
ENDIF.
*------------ Create Deletion Table
DATA: lt_tmp TYPE REF TO data.
ASSIGN lt_tmp TO
IF
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = lt
IMPORTING
ep_table =
EXCEPTIONS
generate_subpool_dir_full = 1
OTHERS = 2.
ASSIGN
IF
ASSIGN
ENDIF.
ENDIF.
*------------ Create Master Table
DATA: lt_xh TYPE REF TO data.
ASSIGN lt_xh TO
IF
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = lt
IMPORTING
ep_table =
EXCEPTIONS
generate_subpool_dir_full = 1
OTHERS = 2.
ASSIGN
IF
ASSIGN
ENDIF.
ENDIF.
ENDFORM. "MYDYNTABLE
FUNCTION zbc_free_table_selections.
*"----------------------------------------------------------------------
*"*"Local Interface:
*" IMPORTING
*" VALUE(TABNAME) LIKE DD02L-TABNAME OPTIONAL
*" REFERENCE(TREE) DEFAULT SPACE
*" EXPORTING
*" REFERENCE(DS_CLAUSES) TYPE RSDS_WHERE
*" EXCEPTIONS
*" TABLE_NOT_VALID
*" OTHER_ERROR
*"----------------------------------------------------------------------
STATICS: lv_init(1).
STATICS: lv_tabname LIKE dd02l-tabname.
STATICS texpr TYPE rsds_texpr.
STATICS twhere TYPE rsds_twhere.
STATICS trange TYPE rsds_trange.
DATA BEGIN OF qcat. "Selections View for
INCLUDE STRUCTURE rsdsqcat. "Free Selectoptions
DATA END OF qcat.
DATA BEGIN OF tabs OCCURS 10.
INCLUDE STRUCTURE rsdstabs.
DATA END OF tabs.
DATA BEGIN OF fields OCCURS 10.
INCLUDE STRUCTURE rsdsfields.
DATA END OF fields.
DATA BEGIN OF efields OCCURS 10.
INCLUDE STRUCTURE rsdsfields.
DATA END OF efields.
STATICS selid LIKE rsdynsel-selid.
STATICS actnum LIKE sy-tfill.
DATA title LIKE sy-title VALUE 'Selection Screen'.
DATA: maxnum LIKE sy-subrc VALUE '69'.
CLEAR tabs.
tabs-prim_tab = tabname.
COLLECT tabs.
DATA: position LIKE dd03l-position.
DATA: keyflag LIKE dd03l-keyflag.
CLEAR fields.
fields-tablename = tabname.
fields-sign = 'I'.
DATA: step LIKE sy-subrc.
IF lv_init <> 'X' AND lv_tabname <> tabname.
lv_tabname = tabname.
SELECT fieldname keyflag position
INTO (fields-fieldname, keyflag, position)
FROM dd03l
WHERE tabname = tabname
AND fieldname NOT LIKE '.INCLU%'
AND datatype NE 'CLNT'
ORDER BY position.
ADD 1 TO step.
CHECK step LE maxnum.
IF keyflag <> 'X'.
efields = fields.
APPEND efields.
ENDIF.
APPEND fields.
ENDSELECT.
IF sy-subrc <> 0.
RAISE table_not_valid.
ENDIF.
CALL FUNCTION 'FREE_SELECTIONS_INIT'
EXPORTING
expressions = texpr
kind = 'T'
IMPORTING
selection_id = selid
expressions = texpr
where_clauses = twhere
field_ranges = trange
number_of_active_fields = actnum
TABLES
tables_tab = tabs
fields_tab = fields
fields_not_selected = efields
EXCEPTIONS
fields_incomplete = 01
fields_no_join = 02
field_not_found = 03
no_tables = 04
table_not_found = 05
expression_not_supported = 06
incorrect_expression = 07
illegal_kind = 08
area_not_found = 09
inconsistent_area = 10
kind_f_no_fields_left = 11
kind_f_no_fields = 12
too_many_fields = 13.
lv_init = 'X'.
ENDIF.
IF NOT lv_init IS INITIAL.
CALL FUNCTION 'FREE_SELECTIONS_DIALOG'
EXPORTING
selection_id = selid
title = title
TREE_VISIBLE = tree
IMPORTING
where_clauses = twhere
expressions = texpr
field_ranges = trange
number_of_active_fields = actnum
TABLES
fields_tab = fields
EXCEPTIONS
internal_error = 01
no_action = 02
no_fields_selected = 03
no_tables_selected = 04
selid_not_found = 05.
IF sy-subrc = 0.
CLEAR ds_clauses.
MOVE tabname TO ds_clauses-tablename.
READ TABLE twhere WITH KEY ds_clauses-tablename INTO ds_clauses.
IF sy-subrc <> 0.
RAISE other_error.
ENDIF.
ELSE.
RAISE other_error.
ENDIF.
ELSE.
RAISE other_error.
ENDIF.
ENDFUNCTION.
No comments:
Post a Comment