TYPE-POOLS: usmd6.
DEFINE display_error_message.
LOOP AT lt_message TRANSPORTING NO FIELDS
WHERE msgty CA 'AEX'.
ENDLOOP.
IF sy-subrc IS INITIAL.
LOOP AT lt_message INTO ls_message
WHERE msgty CA 'AEX'.
PERFORM write_message
USING ls_message-msgid
ls_message-msgty
ls_message-msgno
ls_message-msgv1
ls_message-msgv2
ls_message-msgv3
ls_message-msgv4
CHANGING msg_output.
WRITE: / msg_output.
CLEAR: msg_output.
ENDLOOP.
RETURN.
ENDIF.
END-OF-DEFINITION.
DEFINE selection_screen.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN POSITION 5.
SELECTION-SCREEN COMMENT 10(40) &2 FOR FIELD &1.
SELECTION-SCREEN END OF LINE.
END-OF-DEFINITION.
TYPE-POOLS: usmd0, usmd1.
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE txtb1.
PARAMETERS:
p_model TYPE usmd600c-usmd_model,
p_entity TYPE usmd600c-usmd_entity,
p_edtn TYPE usmd_edition,
p_trvari TYPE usmd600c-usmd_trvari,
p_trkind TYPE usmd6010-usmd_trkind,
p_fname TYPE usmd6010-usmd_fname LOWER CASE,
p_creq TYPE usmd120c-usmd_crequest OBLIGATORY.
SELECTION-SCREEN END OF BLOCK b1.
START-OF-SELECTION.
PERFORM start_upload.
*----------------------------------------------------------------------*
* CLASS lcl_file_reader DEFINITION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS lcl_file_reader DEFINITION.
PUBLIC SECTION.
METHODS:
constructor IMPORTING
io_data_transfer TYPE REF TO cl_usmd_data_transfer,
load_file,
get_file_data EXPORTING
et_data TYPE usmd_t_charline.
PROTECTED SECTION.
DATA:
do_data_transfer TYPE REF TO cl_usmd_data_transfer,
dt_data TYPE usmd_t_charline,
ds_usmd600c TYPE usmd600c,
ds_usmd6010 TYPE usmd6010.
ENDCLASS. "lcl_file_reader DEFINITION
*----------------------------------------------------------------------*
* CLASS lcl_file_reader IMPLEMENTATION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS lcl_file_reader IMPLEMENTATION.
METHOD constructor.
do_data_transfer = io_data_transfer.
ENDMETHOD. "constructor
METHOD load_file.
DATA:
l_fileintern TYPE fileintern,
l_fileextern TYPE fileextern,
l_mesg TYPE char50,
ls_data TYPE usmd_charline,
l_read_result TYPE sysubrc,
l_subrc TYPE sysubrc.
CLEAR dt_data.
CALL METHOD do_data_transfer->dt_get_gui_data
IMPORTING
es_usmd600c = ds_usmd600c
es_usmd6010 = ds_usmd6010.
* open file
CASE ds_usmd6010-usmd_fileloc.
WHEN 'P'.
CLEAR dt_data.
CALL METHOD cl_gui_frontend_services=>gui_upload
EXPORTING
filename = ds_usmd6010-usmd_fname
filetype = 'ASC'
CHANGING
data_tab = dt_data
EXCEPTIONS
file_open_error = 1
file_read_error = 2
no_batch = 4
access_denied = 6
no_authority = 6
OTHERS = 1.
l_subrc = sy-subrc.
CASE l_subrc.
WHEN 01.
l_mesg = 'Datei konnte nicht geöffnet werden'(ul1).
WHEN 02.
l_mesg = 'Datei konnte nicht gelesen werden'(ul2).
WHEN 04.
l_mesg = 'Fkt. in Hintergrundverarb. nicht möglich'(ul3).
WHEN 06.
l_mesg = 'Keine Zugriffsberechtigung'(ul4).
ENDCASE.
WHEN 'A'.
* open dataset without using logical filenames should not be used anymore
MESSAGE e325(usmd6).
WHEN 'L'.
l_fileintern = ds_usmd6010-usmd_fname.
CALL FUNCTION 'FILE_GET_NAME'
EXPORTING
logical_filename = l_fileintern
IMPORTING
file_name = l_fileextern
EXCEPTIONS
file_not_found = 01.
IF sy-subrc <> 0.
"Logische Datei &1 nicht gefunden
MESSAGE e017(usmd6) WITH l_fileintern.
ENDIF.
OPEN DATASET l_fileextern IN TEXT MODE ENCODING DEFAULT FOR INPUT
WITH SMART LINEFEED MESSAGE l_mesg.
l_subrc = sy-subrc.
IF l_subrc IS INITIAL.
CLEAR l_read_result.
WHILE l_read_result IS INITIAL.
READ DATASET l_fileextern INTO ls_data.
l_read_result = sy-subrc.
IF l_read_result IS INITIAL.
APPEND ls_data TO dt_data.
ENDIF.
ENDWHILE.
CLOSE DATASET l_fileextern.
ENDIF.
ENDCASE.
IF l_subrc <> 0.
* Datei &1 konnte nicht geöffnet werden! Meldung: &2
MESSAGE e018(usmd6) WITH l_fileextern l_mesg.
ENDIF.
ENDMETHOD. "load_file
METHOD get_file_data.
et_data = dt_data.
ENDMETHOD. "get_file_data
ENDCLASS. "lcl_file_reader IMPLEMENTATION
*&---------------------------------------------------------------------*
*& Form start_upload
*&---------------------------------------------------------------------*
* start upload
*----------------------------------------------------------------------*
FORM start_upload.
DATA:
lo_data_transfer TYPE REF TO cl_usmd_data_transfer,
lo_file_reader TYPE REF TO lcl_file_reader,
lt_message TYPE usmd_t_message,
ls_message TYPE usmd_s_message,
lo_ex TYPE REF TO cx_usmd_exception,
ls_usmd600c TYPE usmd600c,
ls_usmd6010 TYPE usmd6010,
lt_field TYPE STANDARD TABLE OF sval,
ls_field TYPE sval,
l_code TYPE char1,
lf_creq_required TYPE usmd_flg,
lf_stop_at_screen TYPE usmd_flg,
lt_data_ext TYPE usmd_t_charline,
lt_ffix TYPE usmd_ts_value,
ls_value TYPE usmd_s_value,
l_fieldname TYPE usmd_fieldname,
lt_crequest TYPE usmd_ts_crequest,
ls_crequest TYPE usmd_s_crequest,
lo_model TYPE REF TO if_usmd_model,
msg_output TYPE string.
TRY.
ls_usmd600c-usmd_model = p_model.
ls_usmd600c-usmd_trvari = p_trvari.
ls_usmd600c-usmd_entity = p_entity.
CALL METHOD cl_usmd_model=>get_instance
EXPORTING
i_usmd_model = p_model
IMPORTING
eo_instance = lo_model
et_message = lt_message.
display_error_message.
CALL METHOD cl_usmd_data_transfer=>get_instance
EXPORTING
i_trkind = p_trkind
is_usmd600c = ls_usmd600c
if_only_runtime = 'X'
RECEIVING
ro_instance = lo_data_transfer.
IF p_edtn IS NOT INITIAL.
lo_data_transfer->set_edition( p_edtn ).
ENDIF.
CALL METHOD lo_data_transfer->dt_get_gui_data
IMPORTING
es_usmd6010 = ls_usmd6010.
ls_usmd6010-usmd_fname = p_fname.
CALL METHOD lo_data_transfer->dt_set_gui_data
EXPORTING
is_usmd6010 = ls_usmd6010.
CALL METHOD lo_data_transfer->dt_check
EXPORTING
if_for_download = space
if_strict = 'X'
IMPORTING
et_message = lt_message.
display_error_message.
CREATE OBJECT lo_file_reader
EXPORTING
io_data_transfer = lo_data_transfer.
lo_file_reader->load_file( ).
CALL METHOD lo_file_reader->get_file_data
IMPORTING
et_data = lt_data_ext.
CALL METHOD lo_data_transfer->if_usmd_upload~set_and_analyze_data
EXPORTING
it_data_ext = lt_data_ext
IMPORTING
et_message = lt_message
ef_creq_required = lf_creq_required
ef_stop_at_screen = lf_stop_at_screen.
display_error_message.
IF lf_stop_at_screen = 'X'.
RETURN.
ENDIF.
"get crequest
IF lf_creq_required = 'X'.
*
CALL METHOD lo_data_transfer->get_fieldname_entity
IMPORTING
e_fieldname = l_fieldname.
ls_value-fieldname = usmd0_cs_fld-fieldname.
ls_value-value = l_fieldname.
INSERT ls_value INTO TABLE lt_ffix.
IF p_edtn IS NOT INITIAL.
ls_value-fieldname = usmd0_cs_fld-edition.
ls_value-value = p_edtn.
INSERT ls_value INTO TABLE lt_ffix.
ENDIF.
CALL METHOD cl_usmd_crequest=>read_valid_crequests
EXPORTING
it_ffix = lt_ffix
io_model = lo_model
if_ignore_obj_list = space "kls
IMPORTING
et_crequest = lt_crequest.
IF lt_crequest IS INITIAL.
MESSAGE e047(usmd6).
ENDIF.
* READ TABLE lt_crequest INTO ls_crequest INDEX 1.
READ TABLE lt_crequest INTO ls_crequest WITH TABLE KEY usmd_crequest = p_creq.
IF ls_crequest IS INITIAL.
MESSAGE 'Given Change Request does not exists' TYPE 'E'.
ENDIF.
ELSE.
CLEAR ls_crequest.
ENDIF.
CALL METHOD lo_data_transfer->if_usmd_upload~check_data
EXPORTING
i_crequest = ls_crequest-usmd_crequest
IMPORTING
et_message = lt_message.
LOOP AT lt_message TRANSPORTING NO FIELDS WHERE msgty CA 'AEX'.
lo_data_transfer->if_usmd_upload~abort( ).
EXIT.
ENDLOOP.
display_error_message.
CALL METHOD lo_data_transfer->if_usmd_upload~post_data
IMPORTING
et_message = lt_message.
display_error_message.
* WRITE: / 'Upload beendet'(011).
WRITE: / '*-----------PROGRAM Execution Parameters-----------*'.
WRITE: / 'Data Model:'.
WRITE: p_model.
WRITE: / 'Entity Type:'.
WRITE: p_entity.
WRITE: / 'Edition:'.
WRITE: p_edtn.
WRITE: / 'Data Transfer Variant:'.
WRITE: p_trvari.
WRITE: / 'Type Of Transfer:'.
WRITE: p_trkind.
WRITE: / 'File Name:'.
WRITE: p_fname.
WRITE: / 'Change Request:'.
WRITE: p_creq.
WRITE: / '*--------------Additional Information--------------*'.
WRITE: / 'User Name:'.
WRITE: sy-uname.
SELECT SINGLE name_textc INTO @DATA(lv_fullname) "#EC CI_NOORDER
FROM user_addr WHERE bname EQ @sy-uname.
WRITE: / 'Full Name:'.
WRITE: lv_fullname.
CLEAR lv_fullname.
CONCATENATE sy-datlo sy-timlo sy-zonlo INTO DATA(lv_stamp) SEPARATED BY '/'.
WRITE: / 'Date & Timing:'.
WRITE: lv_stamp.
CLEAR lv_stamp.
WRITE: / 'Upload beendet'(011).
CATCH cx_usmd_exception INTO lo_ex.
lt_message = lo_ex->dt_message.
display_error_message.
ENDTRY.
ENDFORM. "start_upload
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_model.
PERFORM f4_model.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_entity.
PERFORM f4_entity.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_trvari.
PERFORM f4_trvari.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_edtn.
PERFORM f4_edtn.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_trkind.
PERFORM f4_trkind.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_fname.
PERFORM f4_fname.
* PERFORM f_read_cr_data.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_creq.
PERFORM f4_creq.
AT SELECTION-SCREEN ON p_creq.
PERFORM f4_creq_validation.
*&---------------------------------------------------------------------*
*& Form f4_trvari
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM f4_trvari.
DATA:
l_entity TYPE string,
l_model TYPE string,
l_trvari TYPE string.
PERFORM read_param_from_dynp
USING 'P_MODEL'
CHANGING l_model.
CHECK l_model IS NOT INITIAL.
MOVE l_model TO p_model.
PERFORM read_param_from_dynp
USING 'P_ENTITY'
CHANGING l_entity.
CHECK l_entity IS NOT INITIAL.
MOVE l_entity TO p_entity.
PERFORM val_help_trvari
USING p_model p_entity
CHANGING l_trvari.
p_trvari = l_trvari.
ENDFORM. "f4_trvari
*&---------------------------------------------------------------------*
*& Form val_help_trvari
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->I_MODEL text
* -->I_ENTITY text
* -->C_TRVARI text
*----------------------------------------------------------------------*
FORM val_help_trvari
USING
i_model TYPE usmd_model
i_entity TYPE usmd_entity
CHANGING c_trvari TYPE string.
DATA:
l_trvari TYPE usmd_trvari,
lt_trvari TYPE cl_usmd_data_transfer=>ty_t_trvari,
value_tab TYPE STANDARD TABLE OF seahlpres WITH KEY string,
ls_value TYPE seahlpres,
title TYPE string,
retfield TYPE dfies-fieldname,
fields TYPE string.
CALL METHOD cl_usmd_data_transfer=>available_trvaris_per_entity
EXPORTING
i_model = i_model
i_entity = i_entity
IMPORTING
et_trvari = lt_trvari.
LOOP AT lt_trvari INTO l_trvari.
ls_value-string = l_trvari.
APPEND ls_value TO value_tab.
ENDLOOP.
SORT value_tab.
DELETE ADJACENT DUPLICATES FROM value_tab.
title = 'Varianten'(007).
retfield = 'USMD_TRVARI'.
fields = 'USMD600C-USMD_TRVARI'.
IF lines( value_tab ) EQ 1.
READ TABLE value_tab INTO ls_value INDEX 1.
c_trvari = ls_value-string.
RETURN.
ENDIF.
PERFORM f4_single_selection
USING
c_trvari
fields
retfield
value_tab
title.
ENDFORM. "val_help_trvari
*&---------------------------------------------------------------------*
*& Form f4_model
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM f4_model.
DATA:
l_model TYPE string.
l_model = p_model.
PERFORM value_help_model CHANGING l_model.
p_model = l_model.
ENDFORM. "f4_model
*&---------------------------------------------------------------------*
*& Form value_help_model
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->C_MODEL text
*----------------------------------------------------------------------*
FORM value_help_model
CHANGING c_model TYPE string.
DATA: value_tab TYPE STANDARD TABLE OF seahlpres,
ls_model TYPE usmd_s_model,
lt_model TYPE usmd_ts_model.
CALL METHOD cl_usmd_model=>get_models
IMPORTING
et_model = lt_model.
CHECK lt_model IS NOT INITIAL.
LOOP AT lt_model INTO ls_model.
APPEND ls_model-usmd_model TO value_tab.
ENDLOOP.
DATA: title TYPE string,
retfield TYPE dfies-fieldname,
fields TYPE string.
title = 'Datenmodelle'(012).
retfield = 'USMD_MODEL'.
fields = 'USMD600C-USMD_MODEL'.
PERFORM f4_single_selection
USING
c_model
fields
retfield
value_tab
title.
ENDFORM. "value_help_model
*&---------------------------------------------------------------------*
*& Form f4_entity
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->C_ENTITY text
*----------------------------------------------------------------------*
FORM f4_entity.
DATA: l_entity TYPE string.
DATA: l_model TYPE string.
PERFORM read_param_from_dynp
USING 'P_MODEL'
CHANGING l_model.
CHECK l_model IS NOT INITIAL.
MOVE l_model TO p_model.
PERFORM val_help_entity
USING p_model
CHANGING l_entity.
p_entity = l_entity.
ENDFORM. "f4_entity
*&---------------------------------------------------------------------*
*& Form val_help_entity
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->I_MODEL text
* -->C_ENTITY text
*----------------------------------------------------------------------*
FORM val_help_entity
USING i_model TYPE usmd_model
CHANGING c_entity TYPE string.
DATA:
ls_entity TYPE usmd_s_entity,
lt_entity TYPE usmd_ts_entity,
value_tab TYPE STANDARD TABLE OF seahlpres WITH KEY string,
ls_value TYPE seahlpres,
title TYPE string,
retfield TYPE dfies-fieldname,
fields TYPE string.
CALL METHOD cl_usmd_model=>get_model_definition
EXPORTING
i_usmd_model = i_model
IMPORTING
et_entity = lt_entity.
LOOP AT lt_entity INTO ls_entity.
ls_value-string = ls_entity-usmd_entity.
APPEND ls_value TO value_tab.
ENDLOOP.
SORT value_tab.
DELETE ADJACENT DUPLICATES FROM value_tab.
title = 'Entitätstypen'(013).
retfield = 'USMD_ENTITY'.
fields = 'USMD600C-USMD_ENTITY'.
PERFORM f4_single_selection
USING
c_entity
fields
retfield
value_tab
title.
ENDFORM. "val_help_entity
*&---------------------------------------------------------------------*
*& Form f4_trkind
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM f4_trkind.
DATA:
l_entity TYPE string,
l_model TYPE string,
l_dwn TYPE string,
lt_message TYPE usmd_t_message,
lts_entity TYPE usmd_ts_entity,
c_trkind TYPE string,
value_tab TYPE STANDARD TABLE OF seahlpres
WITH KEY string,
ls_value TYPE seahlpres,
title TYPE string,
retfield TYPE dfies-fieldname,
fields TYPE string.
FIELD-SYMBOLS:
<ls_entity> TYPE usmd_s_entity.
PERFORM read_param_from_dynp
USING 'P_MODEL'
CHANGING l_model.
CHECK l_model IS NOT INITIAL.
MOVE l_model TO p_model.
PERFORM read_param_from_dynp
USING 'P_ENTITY'
CHANGING l_entity.
CHECK l_entity IS NOT INITIAL.
MOVE l_entity TO p_entity.
CALL METHOD cl_usmd_model=>get_model_definition
EXPORTING
i_usmd_model = p_model
IMPORTING
et_entity = lts_entity.
LOOP AT lt_message TRANSPORTING NO FIELDS
WHERE msgty CA 'AEX'.
RETURN.
ENDLOOP.
READ TABLE lts_entity ASSIGNING <ls_entity>
WITH TABLE KEY usmd_entity = p_entity.
IF sy-subrc IS NOT INITIAL.
BREAK-POINT ID usmd1.
RETURN.
ENDIF.
* attributes can be downloaded always
ls_value-string = usmd6_cs_trkind-attribute.
APPEND ls_value TO value_tab.
ls_value-string = 'Stammdaten'(020).
APPEND ls_value TO value_tab.
IF <ls_entity>-usage_type EQ usmd0_cs_usage_type-fin_mdm OR
<ls_entity>-usage_type EQ usmd0_cs_usage_type-checktab_gen OR
<ls_entity>-usage_type EQ usmd0_cs_usage_type-checktab_fix.
ls_value-string = usmd6_cs_trkind-text.
APPEND ls_value TO value_tab.
ls_value-string = 'Language-Dep. Texts'(021).
APPEND ls_value TO value_tab.
IF <ls_entity>-f_has_hry = abap_true.
ls_value-string = usmd6_cs_trkind-hry.
APPEND ls_value TO value_tab.
ls_value-string = 'Hierarchies'(022).
APPEND ls_value TO value_tab.
ENDIF.
ENDIF.
title = 'Art des Transfers'(014).
retfield = 'USMD_TRKIND'.
fields = 'USMD6010-USMD_TRKIND&USMD6010_S_GUI-USMD_SEP_TEXT'.
IF lines( value_tab ) EQ 1.
READ TABLE value_tab INTO ls_value INDEX 1.
p_trkind = ls_value-string.
RETURN.
ENDIF.
PERFORM f4_single_selection
USING
c_trkind
fields
retfield
value_tab
title.
p_trkind = c_trkind.
ENDFORM. "f4_trkind
*&---------------------------------------------------------------------*
*& Form f4_edtn
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM f4_edtn.
DATA:
l_entity TYPE string,
l_model TYPE string,
l_edition TYPE string,
lts_entity TYPE usmd_ts_entity,
lt_entity_cont TYPE usmd_ts_entity_cont,
lt_message TYPE usmd_t_message,
l_ent TYPE usmd_entity,
l_dwn TYPE string,
lf_download TYPE usmd_flg.
FIELD-SYMBOLS:
<ls_entity> TYPE usmd_s_entity,
<ls_entity_cont> TYPE usmd_s_entity_cont.
PERFORM read_param_from_dynp
USING 'P_MODEL'
CHANGING l_model.
CHECK l_model IS NOT INITIAL.
MOVE l_model TO p_model.
PERFORM read_param_from_dynp
USING 'P_ENTITY'
CHANGING l_entity.
CHECK l_entity IS NOT INITIAL.
MOVE l_entity TO p_entity.
* is it a download or an upload
PERFORM read_param_from_dynp
USING 'P_DWN'
CHANGING l_dwn.
CALL METHOD cl_usmd_model=>get_model_definition
EXPORTING
i_usmd_model = p_model
IMPORTING
et_entity = lts_entity
et_entity_cont = lt_entity_cont
et_message = lt_message.
LOOP AT lt_message TRANSPORTING NO FIELDS
WHERE msgty CA 'AEX'.
RETURN.
ENDLOOP.
READ TABLE lts_entity ASSIGNING <ls_entity>
WITH TABLE KEY usmd_entity = p_entity.
IF sy-subrc IS NOT INITIAL.
BREAK-POINT ID usmd1.
RETURN.
ENDIF.
l_ent = p_entity.
IF <ls_entity>-usage_type EQ usmd0_cs_usage_type-checktab_gen.
RETURN. "no edition required
ENDIF.
IF <ls_entity>-usage_type EQ usmd0_cs_usage_type-contained.
LOOP AT lt_entity_cont ASSIGNING <ls_entity_cont>
WHERE usmd_entity_cont = p_entity. "#EC CI_SORTSEQ
READ TABLE lts_entity ASSIGNING <ls_entity>
WITH TABLE KEY
usmd_entity = <ls_entity_cont>-usmd_entity.
CHECK <ls_entity>-usage_type = usmd0_cs_usage_type-fin_mdm.
l_ent = <ls_entity_cont>-usmd_entity.
EXIT.
ENDLOOP.
ENDIF.
* for upload
lf_download = l_dwn.
PERFORM val_help_edition
USING p_model l_ent lf_download
CHANGING l_edition.
p_edtn = l_edition.
ENDFORM. "f4_edtn
*&---------------------------------------------------------------------*
*& Form f4_single_selection
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->VALUE text
* -->FIELDS text
* -->RETFIELD text
* -->VALUE_TAB text
* -->TITLE text
*----------------------------------------------------------------------*
FORM f4_single_selection
USING
value TYPE string
fields TYPE string
retfield TYPE dfies-fieldname
value_tab TYPE table
title TYPE string.
TYPES:
yt_string TYPE STANDARD TABLE OF string WITH DEFAULT KEY
.
DATA: lt_field TYPE yt_string,
ls_field TYPE string,
tabname TYPE ddobjname,
fieldname TYPE dfies-lfieldname,
field_tab TYPE TABLE OF dfies,
field_wa TYPE dfies,
return_tab TYPE TABLE OF ddshretval,
return_wa TYPE ddshretval,
lc_title(50) TYPE c.
IF value_tab IS INITIAL.
RETURN.
ENDIF.
SPLIT fields AT '&' INTO TABLE lt_field.
LOOP AT lt_field INTO ls_field.
SPLIT ls_field AT '-' INTO tabname fieldname.
CALL FUNCTION 'DDIF_FIELDINFO_GET'
EXPORTING
tabname = tabname
lfieldname = fieldname
IMPORTING
dfies_wa = field_wa
EXCEPTIONS
OTHERS = 1.
IF sy-subrc <> 0.
BREAK-POINT ID usmd1.
RETURN.
ENDIF.
APPEND field_wa TO field_tab.
ENDLOOP.
lc_title = title.
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
retfield = retfield
window_title = lc_title
* value_org = value_org
TABLES
value_tab = value_tab
field_tab = field_tab
return_tab = return_tab
EXCEPTIONS
OTHERS = 1.
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 TABLE return_tab INTO return_wa INDEX 1.
IF sy-subrc <> 0.
RETURN.
ENDIF.
value = return_wa-fieldval.
ENDFORM. "f4_single_selection
*&---------------------------------------------------------------------*
*& Form read_param_from_dynp
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->FIELDNAME text
* -->RETVAL text
*----------------------------------------------------------------------*
FORM read_param_from_dynp
USING fieldname TYPE dynfnam
CHANGING retval TYPE string.
DATA:
dyname TYPE progname
, dynum TYPE sychar04
.
dyname = sy-repid.
dynum = sy-dynnr.
PERFORM read_param_from_dynp2
USING fieldname dyname dynum
CHANGING retval.
ENDFORM. "read_param_from_dynp
*&---------------------------------------------------------------------*
*& Form read_param_from_dynp2
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->FIELDNAME text
* -->DYNAME text
* -->DYNUM text
* -->RETVAL text
*----------------------------------------------------------------------*
FORM read_param_from_dynp2
USING fieldname TYPE dynfnam
dyname TYPE progname
dynum TYPE sychar04
CHANGING retval TYPE string.
DATA:
dynpfields TYPE STANDARD TABLE OF dynpread
, ls_dynpfield TYPE dynpread
.
ls_dynpfield-fieldname = fieldname.
APPEND ls_dynpfield TO dynpfields.
CALL FUNCTION 'DYNP_VALUES_READ'
EXPORTING
dyname = dyname
dynumb = dynum
TABLES
dynpfields = dynpfields
EXCEPTIONS
invalid_abapworkarea = 1
invalid_dynprofield = 2
invalid_dynproname = 3
invalid_dynpronummer = 4
invalid_request = 5
no_fielddescription = 6
invalid_parameter = 7
undefind_error = 8
double_conversion = 9
stepl_not_found = 10
OTHERS = 11.
IF sy-subrc <> 0.
RETURN.
ENDIF.
READ TABLE dynpfields INTO ls_dynpfield WITH KEY
fieldname = fieldname.
IF sy-subrc = 0.
retval = ls_dynpfield-fieldvalue.
ENDIF.
ENDFORM. "read_param_from_dynp2
*&---------------------------------------------------------------------*
*& Form val_help_edition
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->I_MODEL text
* -->I_ENTITY text
* -->IF_IS_DOWNLOAD text
* -->C_EDITION text
*----------------------------------------------------------------------*
FORM val_help_edition
USING
i_model TYPE usmd_model
i_entity TYPE usmd_entity
if_is_download TYPE usmd_flg
CHANGING c_edition TYPE string.
DATA:
lt_edition TYPE usmd_ts_editions,
ls_edition LIKE LINE OF lt_edition,
value_tab TYPE STANDARD TABLE OF seahlpres WITH KEY string,
ls_value TYPE seahlpres,
title TYPE string,
retfield TYPE dfies-fieldname,
fields TYPE string.
PERFORM get_editions
USING i_model i_entity
CHANGING lt_edition.
LOOP AT lt_edition INTO ls_edition.
"do not upload into already released editions!
IF if_is_download IS INITIAL.
CHECK ls_edition-usmd_edtn_status NE
usmd0_cs_edition_status-released.
ENDIF.
ls_value-string = ls_edition-usmd_edition.
APPEND ls_value TO value_tab.
ENDLOOP.
SORT value_tab.
DELETE ADJACENT DUPLICATES FROM value_tab.
title = 'Editionen'(008).
retfield = 'USMD_EDITION'.
fields = 'USMD120C-USMD_EDITION'.
PERFORM f4_single_selection
USING
c_edition
fields
retfield
value_tab
title.
ENDFORM. "val_help_edition
*&---------------------------------------------------------------------*
*& Form get_editions
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->I_MODEL text
* -->I_ENTITY text
* -->CT_EDITION text
*----------------------------------------------------------------------*
FORM get_editions
USING
i_model TYPE usmd_model
i_entity TYPE usmd_entity
CHANGING ct_edition TYPE usmd_ts_editions.
DATA:
lo_edition_api TYPE REF TO if_usmd_edition_api,
lt_edition_type TYPE usmd_ts_edition_type.
FIELD-SYMBOLS:
<ls_edition> LIKE LINE OF ct_edition.
TRY .
lo_edition_api = cl_usmd_edition_factory=>get_edition_api( ).
lt_edition_type = lo_edition_api->get_edition_type_by_model( i_model ).
ct_edition = lo_edition_api->get_editions( ).
LOOP AT ct_edition ASSIGNING <ls_edition>.
READ TABLE lt_edition_type TRANSPORTING NO FIELDS
WITH TABLE KEY usmd_edtn_type = <ls_edition>-usmd_edtn_type.
CHECK sy-subrc IS NOT INITIAL.
DELETE ct_edition.
ENDLOOP.
CATCH cx_usmd_edition. " Exception class for editions
CLEAR ct_edition.
ENDTRY.
ENDFORM. "get_editions
*&---------------------------------------------------------------------*
*& Form write_message
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->VALUE text
* -->(I_MSGID) text
* -->VALUE text
* -->(I_MSGTY) text
* -->VALUE text
* -->(I_MSGNO) text
* -->VALUE text
* -->(I_MSGV1) text
* -->VALUE text
* -->(I_MSGV2) text
* -->VALUE text
* -->(I_MSGV3) text
* -->VALUE text
* -->(I_MSGV4) text
* -->MSGTXT text
*----------------------------------------------------------------------*
FORM write_message
USING VALUE(i_msgid) TYPE usmd_s_message-msgid
VALUE(i_msgty) TYPE usmd_s_message-msgty
VALUE(i_msgno) TYPE usmd_s_message-msgno
VALUE(i_msgv1) TYPE usmd_s_message-msgv1
VALUE(i_msgv2) TYPE usmd_s_message-msgv2
VALUE(i_msgv3) TYPE usmd_s_message-msgv3
VALUE(i_msgv4) TYPE usmd_s_message-msgv4
CHANGING msgtxt TYPE string.
TABLES: t100.
MOVE: sy-langu TO t100-sprsl,
i_msgid TO t100-arbgb,
i_msgno TO t100-msgnr.
READ TABLE t100.
IF sy-subrc NE 0.
MOVE: 'D' TO t100-sprsl.
READ TABLE t100.
ENDIF.
IF sy-subrc NE 0.
CLEAR: i_msgv4.
MOVE: 'E' TO i_msgty,
'CH' TO i_msgid,
'004' TO i_msgno,
'T100' TO i_msgv1,
t100-arbgb TO i_msgv2,
t100-msgnr TO i_msgv3,
syst-langu TO t100-sprsl,
i_msgid TO t100-arbgb,
i_msgno TO t100-msgnr.
READ TABLE t100.
ENDIF.
IF sy-subrc NE 0.
MOVE: 'D' TO t100-sprsl.
READ TABLE t100.
ENDIF.
MOVE: t100-text TO msgtxt.
FIND FIRST OCCURRENCE OF '&1' IN msgtxt.
IF sy-subrc EQ 0.
REPLACE '&1' WITH i_msgv1 INTO msgtxt.
CONDENSE msgtxt.
REPLACE '&2' WITH i_msgv2 INTO msgtxt.
CONDENSE msgtxt.
REPLACE '&3' WITH i_msgv3 INTO msgtxt.
CONDENSE msgtxt.
REPLACE '&4' WITH i_msgv4 INTO msgtxt.
CONDENSE msgtxt.
ELSE.
REPLACE FIRST OCCURRENCE OF '&' IN msgtxt WITH i_msgv1.
REPLACE FIRST OCCURRENCE OF '&' IN msgtxt WITH i_msgv2.
REPLACE FIRST OCCURRENCE OF '&' IN msgtxt WITH i_msgv3.
REPLACE FIRST OCCURRENCE OF '&' IN msgtxt WITH i_msgv4.
CONDENSE msgtxt.
ENDIF.
ENDFORM. "write_message
FORM f4_fname.
DATA:
lt_file_tab TYPE filetable,
lv_rc TYPE sysubrc.
FIELD-SYMBOLS:
<file> TYPE LINE OF filetable.
CALL METHOD cl_gui_frontend_services=>file_open_dialog
EXPORTING
window_title = 'Select file for upload'
default_extension = '*'
* default_filename =
* file_filter =
* with_encoding =
initial_directory = p_fname
* multiselection =
CHANGING
file_table = lt_file_tab
rc = lv_rc.
READ TABLE lt_file_tab INDEX 1 ASSIGNING <file>.
IF sy-subrc = 0.
p_fname = <file>.
ENDIF.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form f4_creq
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& --> p1 text
*& <-- p2 text
*&---------------------------------------------------------------------*
FORM f4_creq_validation .
SELECT COUNT(*)
FROM usmd120c
WHERE usmd_crequest EQ p_creq.
IF sy-subrc NE 0.
MESSAGE 'Given Change Request does not exists' TYPE 'E'.
ENDIF.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form f4_creq
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& --> p1 text
*& <-- p2 text
*&---------------------------------------------------------------------*
FORM f4_creq .
DATA:
lt_usmd120c TYPE STANDARD TABLE OF usmd120c,
lt_return TYPE TABLE OF ddshretval,
lwa_return TYPE ddshretval.
SELECT "#EC CI_NOFIELD
usmd_crequest
usmd_creq_type
usmd_edition
usmd_creq_status
usmd_creq_text
usmd_created_at
usmd_created_by
usmd_changed_at
usmd_changed_by
usmd_released_at
usmd_released_by
usmd_data_chn_at
usmd_data_active
usmd_draft_step
usmd_priority
usmd_due_date
usmd_reason
usmd_reason_rej
usmd_crequest_re
usmd_replic_mode
INTO CORRESPONDING FIELDS OF TABLE lt_usmd120c
FROM usmd120c WHERE ( usmd_creq_status EQ '00' OR usmd_creq_status EQ '01' OR usmd_creq_status EQ '02' OR
usmd_creq_status EQ '03' OR usmd_creq_status EQ '09' OR usmd_creq_status EQ '10' OR usmd_creq_status EQ 'Y1' OR
usmd_creq_status EQ 'Y2' OR usmd_creq_status EQ 'Y3' OR usmd_creq_status EQ 'Y4' OR usmd_creq_status EQ 'Y5' OR
usmd_creq_status EQ 'Y6' OR usmd_creq_status EQ 'Z1' OR usmd_creq_status EQ 'Z2' OR usmd_creq_status EQ 'Z3'
OR usmd_creq_status EQ 'Z4'
) .
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
retfield = 'USMD_CREQUEST'
value_org = 'S'
TABLES
value_tab = lt_usmd120c
return_tab = lt_return
EXCEPTIONS ##FM_SUBRC_OK
parameter_error = 1
no_values_found = 2
OTHERS = 3.
READ TABLE lt_return INTO lwa_return INDEX 1.
IF sy-subrc = 0.
p_creq = lwa_return-fieldval.
ENDIF.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form f_read_cr_data
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& --> p1 text
*& <-- p2 text
*&---------------------------------------------------------------------*
FORM f_read_cr_data .
ENDFORM.
Great and long post.
ReplyDeleteSAP FICO In Telugu
SAP FICO Training In Telugu
SAP FICO Telugu Tutorials