*&---------------------------------------------------------------------*
*& Report ZEV_UPLOAD
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT zev_upload MESSAGE-ID zfi.
TYPE-POOLS truxs.
SELECTION-SCREEN: BEGIN OF BLOCK a WITH FRAME TITLE TEXT-001.
PARAMETER: p_table LIKE dd02l-tabname,
p_file LIKE rlgrap-filename. " DEFAULT 'c:\temp\zcvaa.csv'.
SELECTION-SCREEN: END OF BLOCK a.
DATA: it_tab TYPE REF TO data.
DATA: gt_table TYPE REF TO cl_salv_table.
IF p_table+0(1) NE 'Z'.
MESSAGE s000 WITH 'CBO테이블만 가능합니다' DISPLAY LIKE 'E'.
EXIT.
ENDIF.
CREATE DATA it_tab TYPE TABLE OF (p_table).
FIELD-SYMBOLS: <fs_tab> TYPE STANDARD TABLE.
ASSIGN it_tab->* TO <fs_tab>.
DATA: it_type TYPE truxs_t_text_data.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
field_name = 'P_FILE'
IMPORTING
file_name = p_file.
START-OF-SELECTION.
IF p_table+0(1) NE 'Z'.
MESSAGE e000 WITH 'CBO테이블만 가능합니다'.
EXIT.
ENDIF.
* uploading the data in the file into internal table
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
* I_FIELD_SEPERATOR =
i_line_header = 'X'
i_tab_raw_data = it_type
i_filename = p_file
TABLES
i_tab_converted_data = <fs_tab>
EXCEPTIONS
conversion_failed = 1
OTHERS = 2.
IF sy-subrc NE 0.
MESSAGE ID sy-msgid
TYPE sy-msgty
NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
END-OF-SELECTION.
MODIFY (p_table) FROM TABLE <fs_tab>.
DESCRIBE TABLE <fs_tab> LINES DATA(dcr).
WRITE: dcr, 'lines got updated in table', p_table.
2018년 10월 30일 화요일
템플릿 - Z*PROGRAM ID* _C01
*&---------------------------------------------------------------------*
*& Include ZEVR0010C01
*&---------------------------------------------------------------------*
*******************************
* LOCAL CLASSES: DEFINITION
*******************************
* 클래스 정의
CLASS lcl_def_receiver DEFINITION.
PUBLIC SECTION.
METHODS: handle_top_of_page
FOR EVENT top_of_page OF cl_gui_alv_grid
IMPORTING e_dyndoc_id table_index.
METHODS : handle_toolbar
FOR EVENT toolbar OF cl_gui_alv_grid
IMPORTING sender
e_object
e_interactive.
METHODS : handle_user_command
FOR EVENT user_command OF cl_gui_alv_grid
IMPORTING sender e_ucomm.
METHODS : handle_data_changed
FOR EVENT data_changed OF cl_gui_alv_grid
IMPORTING sender er_data_changed.
METHODS : handle_after_user_command
FOR EVENT after_user_command OF cl_gui_alv_grid.
METHODS : handle_data_changed_finished
FOR EVENT data_changed_finished OF cl_gui_alv_grid
IMPORTING sender e_modified
et_good_cells.
METHODS : handle_hotspot_click
FOR EVENT hotspot_click OF cl_gui_alv_grid
IMPORTING sender e_row_id
e_column_id.
METHODS : handle_double_click
FOR EVENT double_click OF cl_gui_alv_grid
IMPORTING sender
e_row
e_column
es_row_no.
METHODS: handle_on_f4 FOR EVENT onf4 OF cl_gui_alv_grid
IMPORTING sender
e_fieldname
e_fieldvalue
es_row_no
er_event_data
et_bad_cells
e_display.
ENDCLASS. " LCL_DEF_RECEIVER
*******************************
* LOCAL CLASSES: IMPLEMENTATION
*******************************
* 클래스 구현
CLASS lcl_def_receiver IMPLEMENTATION.
METHOD handle_top_of_page.
* PERFORM top_of_page USING e_dyndoc_id table_index.
ENDMETHOD. "HANDLE_TOP_OF_PAGE
METHOD handle_toolbar.
IF sender = go_alv1.
* PERFORM TOOBAR_PART USING SENDER E_OBJECT E_INTERACTIVE.
ENDIF.
ENDMETHOD. "handle_toolbar
*----------------------------------------------------------------------*
* CLASS LCL_EVENT_RECEIVER IMPLEMENTATION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
METHOD handle_after_user_command.
* PERFORM AFTER_USER_COMMAND.
ENDMETHOD. "HANDLE_AFTER_USER_COMMAND
METHOD handle_user_command.
IF sender = go_alv1.
PERFORM user_command_part USING e_ucomm.
ENDIF.
ENDMETHOD. "handle_user_command
METHOD handle_data_changed.
IF sender = go_alv1.
PERFORM data_changed USING er_data_changed.
ENDIF.
ENDMETHOD. "handle_data_changed
METHOD handle_data_changed_finished.
IF sender = go_alv1.
PERFORM data_changed_finished USING e_modified et_good_cells.
ENDIF.
ENDMETHOD. "handle_data_changed_finished
METHOD handle_hotspot_click.
IF sender = go_alv1.
PERFORM hotspot_click USING e_row_id e_column_id.
ENDIF.
ENDMETHOD. "handle_hotspot_click
METHOD handle_double_click.
IF sender = go_alv1.
PERFORM double_click USING e_row e_column es_row_no.
ENDIF.
ENDMETHOD. "handle_double_click
METHOD handle_on_f4.
PERFORM on_f4 USING sender
e_fieldname
e_fieldvalue
es_row_no
er_event_data
et_bad_cells
e_display.
ENDMETHOD. "handle_on_f4
ENDCLASS. " LCL_DEF_RECEIVER
*&---------------------------------------------------------------------*
*& FORM TOOBAR_PART
*&---------------------------------------------------------------------*
* TOOBAR_PART
*----------------------------------------------------------------------*
FORM toobar_part USING sender
p_c_object TYPE REF TO cl_alv_event_toolbar_set
p_interactive.
* PERFORM TOOBAR_PART_100 USING P_C_OBJECT P_INTERACTIVE.
ENDFORM. " TOOBAR_PART
*&---------------------------------------------------------------------*
*& FORM USER_COMMAND_PART
*&---------------------------------------------------------------------*
* TEXT
*----------------------------------------------------------------------*
* -->P_E_UCOMM TEXT
*----------------------------------------------------------------------*
FORM user_command_part USING p_ucomm.
IF p_ucomm EQ 'SUB'.
PERFORM get_selected_row USING go_alv1.
PERFORM user_command.
ENDIF.
ENDFORM. " USER_COMMAND_PART
*&---------------------------------------------------------------------*
*& FORM DATA_CHANGED
*&---------------------------------------------------------------------*
* TEXT
*----------------------------------------------------------------------*
* -->P_ER_DATA_CHANGED TEXT
*----------------------------------------------------------------------*
FORM data_changed USING p_c_data_changed
TYPE REF TO cl_alv_changed_data_protocol.
ENDFORM. " DATA_CHANGED
*&---------------------------------------------------------------------*
*& Form F_OUT_MESSAGE_PROC
*&---------------------------------------------------------------------*
* 에러처리를 한다.
*----------------------------------------------------------------------*
* -->P_DATA_CHANGED text
* -->P_MODF_FIELD text
*----------------------------------------------------------------------*
FORM f_out_message_proc
USING p_data_changed TYPE REF TO cl_alv_changed_data_protocol
p_modf_field TYPE lvc_s_modi
ps_msg TYPE t_msg.
* CALL METHOD P_DATA_CHANGED->ADD_PROTOCOL_ENTRY
* EXPORTING
* I_MSGID = PS_MSG-MSGID
* I_MSGTY = PS_MSG-MSGTY
* I_MSGNO = PS_MSG-MSGNO
* I_MSGV1 = PS_MSG-MSG1
* I_MSGV2 = PS_MSG-MSG2
* I_MSGV3 = PS_MSG-MSG3
* I_MSGV4 = PS_MSG-MSG4
* I_FIELDNAME = P_MODF_FIELD-FIELDNAME
* I_ROW_ID = P_MODF_FIELD-ROW_ID.
ENDFORM. " F_OUT_MESSAGE_PROC
*&---------------------------------------------------------------------*
*& FORM DATA_CHANGED_FINISHED
*&---------------------------------------------------------------------*
* TEXT
*----------------------------------------------------------------------*
* -->P_E_MODIFIED TEXT
* -->P_ET_GOOD_CELLS TEXT
*----------------------------------------------------------------------*
FORM data_changed_finished USING p_e_modified
et_good_cells. " TYPE LVC_T_MODI
ENDFORM. " DATA_CHANGED_FINISHED
*&---------------------------------------------------------------------*
*& FORM HOTSPOT_CLICK
*&---------------------------------------------------------------------*
* TEXT
*----------------------------------------------------------------------*
* -->P_E_ROW_ID TEXT
* -->P_E_COLUMN_ID TEXT
*----------------------------------------------------------------------*
FORM hotspot_click USING p_row_id
p_column_id.
IF p_column_id EQ 'BELNR'.
IF p_sel01 EQ 'X'.
CLEAR gs_card.
READ TABLE gt_card INTO gs_card INDEX p_row_id.
CHECK sy-subrc EQ 0.
ELSEIF p_sel02 EQ 'X'.
CLEAR gs_dti.
READ TABLE gt_dti INTO gs_dti INDEX p_row_id.
CHECK sy-subrc EQ 0.
ELSEIF p_sel03 EQ 'X'.
CLEAR gs_etc.
READ TABLE gt_etc INTO gs_etc INDEX p_row_id.
CHECK sy-subrc EQ 0.
ENDIF.
ENDIF.
ENDFORM. " HOTSPOT_CLICK
*&---------------------------------------------------------------------*
*& FORM DOUBLE_CLICK
*&---------------------------------------------------------------------*
* TEXT
*----------------------------------------------------------------------*
* -->P_E_ROW TEXT
* -->P_E_COLUMN TEXT
* -->P_ES_ROW_NO TEXT
*----------------------------------------------------------------------*
FORM double_click USING p_row TYPE lvc_s_row
p_column
p_s_row_no.
RANGES : lr_cardno FOR ztficd10-zcardno,
lr_mail FOR zdti_header-zbyre,
lr_supno FOR zdti_header-supno,
lr_pernr FOR usr02-bname.
CHECK p_row-index NE 0.
IF p_sel01 EQ 'X'.
CLEAR gs_card.
READ TABLE gt_card INTO gs_card INDEX p_row-index.
add_range_eq_space : lr_cardno gs_card-zcardno.
ELSEIF p_sel02 EQ 'X'.
CLEAR gs_dti.
READ TABLE gt_dti INTO gs_dti INDEX p_row-index.
add_range_eq_space : lr_mail gs_dti-email,
lr_supno gs_dti-supno.
ELSEIF p_sel03 EQ 'X'.
CLEAR gs_etc.
READ TABLE gt_etc INTO gs_etc INDEX p_row-index.
add_range_eq_space : lr_pernr gs_etc-empno.
ENDIF.
SUBMIT zevr0020 USING SELECTION-SCREEN 1000
WITH p_bukrs EQ p_bukrs
WITH s_budat IN s_budat
WITH p_sel01 EQ p_sel01
WITH p_sel02 EQ p_sel02
WITH p_sel03 EQ p_sel03
WITH p_tot EQ p_tot
WITH p_fi EQ p_fi
WITH p_tr EQ p_tr
WITH s_cardno IN lr_cardno
WITH s_mail IN lr_mail
WITH s_supno IN lr_supno
WITH s_pernr IN lr_pernr
AND RETURN.
ENDFORM. " DOUBLE_CLICK
*&---------------------------------------------------------------------*
*& Form ON_F4
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_SENDER text
* -->P_E_FIELDNAME text
* -->P_E_FIELDVALUE text
* -->P_ES_ROW_NO text
* -->P_ER_EVENT_DATA text
* -->P_ET_BAD_CELLS text
* -->P_E_DISPLAY text
*----------------------------------------------------------------------*
FORM on_f4 USING p_c_sender TYPE REF TO cl_gui_alv_grid
p_fieldname TYPE lvc_fname
p_fieldvalue TYPE lvc_value
p_s_row_no TYPE lvc_s_roid
p_c_event_data TYPE REF TO cl_alv_event_data
p_t_bad_cells TYPE lvc_t_modi
p_display TYPE char01.
* PERFORM ON_F4_100 USING P_C_SENDER
* P_FIELDNAME
* P_FIELDVALUE
* P_S_ROW_NO
* P_C_EVENT_DATA
* P_T_BAD_CELLS
* P_DISPLAY.
ENDFORM. " ON_F4
*&---------------------------------------------------------------------*
*& Form ON_F4_100
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_P_C_SENDER text
* -->P_P_FIELDNAME text
* -->P_P_FIELDVALUE text
* -->P_P_S_ROW_NO text
* -->P_P_C_EVENT_DATA text
* -->P_P_T_BAD_CELLS text
* -->P_P_DISPLAY text
*----------------------------------------------------------------------*
*FORM ON_F4_100 USING P_C_SENDER TYPE REF TO CL_GUI_ALV_GRID
* P_FIELDNAME TYPE LVC_FNAME
* P_FIELDVALUE TYPE LVC_VALUE
* P_S_ROW_NO TYPE LVC_S_ROID
* P_C_EVENT_DATA TYPE REF TO CL_ALV_EVENT_DATA
* P_T_BAD_CELLS TYPE LVC_T_MODI
* P_DISPLAY TYPE CHAR01.
*
* DATA : LT_RETURN LIKE DDSHRETVAL OCCURS 0 WITH HEADER LINE.
* DATA : LS_LVC_MODI TYPE LVC_S_MODI.
*
* FIELD-SYMBOLS : <FS_DATA> TYPE LVC_T_MODI.
* CLEAR : P_DISPLAY .
*
* CASE P_FIELDNAME.
* WHEN 'MEINS'.
* ENDCASE.
*
*ENDFORM. " ON_F4_100
*&---------------------------------------------------------------------*
*& Form SET_ALV_LIST
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_LCL_GRID text
* -->P_0062 text
* -->P_0063 text
*----------------------------------------------------------------------*
FORM display_alv_list USING pv_alv_grid TYPE REF TO lcl_def_grid
p_tname
p_cnt.
* 로컬변수선언
DATA : lv_table LIKE feld-name.
FIELD-SYMBOLS : <table> TYPE STANDARD TABLE,
<ft_fcat> TYPE STANDARD TABLE,
<ft_sort> TYPE STANDARD TABLE,
<ft_func> TYPE STANDARD TABLE,
<fs_layo> TYPE any.
DATA : l_subrc LIKE sy-subrc.
DATA : l_fieldname LIKE dd03l-fieldname.
CONCATENATE p_tname '[]' INTO lv_table.
ASSIGN (lv_table) TO <table>.
*-- TOOLBAR ASSIGN
CONCATENATE 'GT_UI_FUNCTIONS' p_cnt INTO lv_table.
ASSIGN (lv_table) TO <ft_func>.
*-- FIELDCAT ASSIGN
CONCATENATE 'GT_LVC_FCAT' p_cnt '[]' INTO lv_table.
ASSIGN (lv_table) TO <ft_fcat>.
*-- GT_LVC_SORT ASSIGN
CONCATENATE 'GT_LVC_SORT' p_cnt '[]' INTO lv_table.
ASSIGN (lv_table) TO <ft_sort>.
PERFORM check_sort_parameter USING <ft_fcat>[] <ft_sort>[]
CHANGING l_fieldname l_subrc.
IF l_subrc NE 0.
CONCATENATE l_fieldname ` : `
`Not Exist SORT Field` INTO l_fieldname.
MESSAGE s000 DISPLAY LIKE 'E' WITH l_fieldname.
EXIT.
ENDIF.
CONCATENATE 'GS_LVC_LAYO' p_cnt INTO lv_table.
ASSIGN (lv_table) TO <fs_layo>.
SORT <table>.
CHECK NOT pv_alv_grid IS INITIAL.
* gv_consistency_check = 'X'.
CALL METHOD pv_alv_grid->set_table_for_first_display
EXPORTING
is_variant = gs_variant
i_save = 'A'
i_default = 'X'
is_layout = <fs_layo>
i_consistency_check = gv_consistency_check
it_toolbar_excluding = <ft_func>
CHANGING
it_outtab = <table>
it_fieldcatalog = <ft_fcat>
it_sort = <ft_sort>
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 4.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDFORM. " SET_ALV_LIST
*&---------------------------------------------------------------------*
*& Form SET_FIELDCATALOG_MERGE_X01
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_C_STRUC text
* <--P_GT_LVC_FCAT1 text
*----------------------------------------------------------------------*
FORM set_fcat_ddic_x01
USING p_strnam LIKE dd02l-tabname
CHANGING p_t_lvc_fcat TYPE lvc_t_fcat.
DATA : ls_lvc_fcat TYPE lvc_s_fcat.
DATA : lt_dd03t TYPE TABLE OF dd03t WITH HEADER LINE.
CLEAR: p_t_lvc_fcat, p_t_lvc_fcat[], ls_lvc_fcat.
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
i_structure_name = p_strnam
i_bypassing_buffer = 'X'
CHANGING
ct_fieldcat = p_t_lvc_fcat
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
*-- 사용자 정의 구조 추가
* PERFORM FILL_FIELD_CATALOGS TABLES P_T_LVC_FCAT USING:
* 'S' 'FIELDNAME' 'STATUS',
* ' ' 'KEY' 'X',
* ' ' 'JUST' 'C',
* ' ' 'OUTPUTLEN' '3',
* ' ' 'ICON' 'X',
* ' ' 'COL_POS' '1',
* ' ' 'REF_TABLE' 'ICON',
* ' ' 'REF_FIELD' 'ID',
* 'E' 'SCRTEXT_L' 'STATUS',
*
* 'S' 'FIELDNAME' 'MESSAGE',
* ' ' 'JUST' 'L',
* ' ' 'OUTPUTLEN' '60',
* ' ' 'COL_POS' '90',
* ' ' 'DATATYPE' 'CHAR',
* ' ' 'INTLEN' '255',
* 'E' 'SCRTEXT_L' 'MESSAGE'.
LOOP AT p_t_lvc_fcat INTO ls_lvc_fcat.
*-- 숫자는 오른쪽 정렬
IF ls_lvc_fcat-datatype EQ 'DEC' OR ls_lvc_fcat-datatype CP 'INT+'
OR ls_lvc_fcat-datatype EQ 'QUAN' OR ls_lvc_fcat-datatype EQ 'CURR'.
ls_lvc_fcat-just = 'R'.
ENDIF.
**-- 필드별 속성 재정의
* PERFORM FCAT_SCR_0100_X01 USING P_STRNAM
* CHANGING LS_LVC_FCAT.
*- 필드 텍스트 넣기
IF ls_lvc_fcat-scrtext_l IS NOT INITIAL.
ls_lvc_fcat-coltext = ls_lvc_fcat-scrtext_l.
ELSE.
ls_lvc_fcat-coltext = ls_lvc_fcat-reptext.
ENDIF.
ls_lvc_fcat-seltext = ls_lvc_fcat-coltext.
MODIFY p_t_lvc_fcat FROM ls_lvc_fcat.
ENDLOOP.
ENDFORM. " SET_FIELDCATALOG_MERGE_X01
*&---------------------------------------------------------------------*
*& Form FILL_FIELD_CATALOGS
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_T_LVC_FCAT text
* -->P_GUB text
* -->P_FNAME text
* -->P_VALUE text
*----------------------------------------------------------------------*
FORM fill_field_catalogs TABLES p_t_lvc_fcat TYPE lvc_t_fcat
USING p_gub p_fname p_value.
IF p_gub = 'S'.
CLEAR gs_lvc_fcat.
ENDIF.
DATA l_fname(40).
FIELD-SYMBOLS <fs> TYPE any.
CONCATENATE 'GS_LVC_FCAT-' p_fname INTO l_fname.
ASSIGN (l_fname) TO <fs>.
<fs> = p_value.
IF p_gub = 'E'.
APPEND gs_lvc_fcat TO p_t_lvc_fcat.
ENDIF.
ENDFORM. " FILL_FIELD_CATALOGS
*&---------------------------------------------------------------------*
*& Form FILL_FCAT_X01
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_&1 text
* -->P_&2 text
* -->P_&3 text
* -->P_P_SFCAT text
* -->P_P_TFCAT text
* -->P_P_RFCAT text
*----------------------------------------------------------------------*
FORM fill_fcat USING p_gub p_fname p_con
p_sfcat TYPE lvc_s_fcat
p_tfcat TYPE lvc_t_fcat
p_ref_fcat TYPE lvc_t_fcat.
DATA : ls_fcat TYPE lvc_s_fcat.
CLEAR : ls_fcat.
IF p_gub = 'S'. " 시작에서 담고 계속 돌면서..''E'를 만났을 때 APPEND해준다.
CLEAR p_sfcat.
READ TABLE p_ref_fcat INTO ls_fcat
WITH KEY fieldname = p_fname.
MOVE-CORRESPONDING ls_fcat TO p_sfcat.
p_sfcat-fieldname = p_fname.
"gt_fieldcat_h와 gs_fieldcat에서 Name이 다른 Field 정보를 넘겨준다.
p_sfcat-scrtext_l = ls_fcat-scrtext_l.
p_sfcat-scrtext_m = ls_fcat-scrtext_m.
p_sfcat-scrtext_s = ls_fcat-scrtext_s.
p_sfcat-reptext = ls_fcat-reptext.
p_sfcat-colddictxt = ls_fcat-colddictxt.
p_sfcat-ref_field = ls_fcat-ref_field.
p_sfcat-ref_table = ls_fcat-ref_table.
p_sfcat-roundfield = ls_fcat-roundfield.
p_sfcat-decmlfield = ls_fcat-decmlfield.
p_sfcat-decimals = ls_fcat-decimals.
EXIT.
ENDIF.
DATA : l_col(40).
FIELD-SYMBOLS : <fs>.
CONCATENATE 'GS_LVC_FCAT-' p_fname INTO l_col.
ASSIGN (l_col) TO <fs>.
MOVE p_con TO <fs>.
IF p_gub = 'E'.
IF p_sfcat-datatype = 'CURR'.
IF p_sfcat-cfieldname IS INITIAL
AND p_sfcat-currency IS INITIAL.
READ TABLE p_ref_fcat INTO ls_fcat
WITH KEY datatype = 'CUKY'.
IF sy-subrc EQ 0.
p_sfcat-cfieldname = ls_fcat-fieldname.
ELSE.
p_sfcat-currency = 'KRW'.
ENDIF.
ENDIF.
ENDIF.
IF p_sfcat-datatype = 'QUAN'.
IF p_sfcat-qfieldname IS INITIAL.
READ TABLE p_ref_fcat INTO ls_fcat
WITH KEY datatype = 'UNIT'.
IF sy-subrc EQ 0.
p_sfcat-qfieldname = ls_fcat-fieldname.
ENDIF.
ENDIF.
ENDIF.
gv_alv_colpos = gv_alv_colpos + 1.
p_sfcat-col_pos = gv_alv_colpos.
IF p_sfcat-outputlen IS INITIAL.
p_sfcat-outputlen = ls_fcat-intlen + 2.
ENDIF.
" 숫자형은 오른쪽 정렬.
IF p_sfcat-datatype EQ 'DEC' OR p_sfcat-datatype CP 'INT+'
OR p_sfcat-datatype EQ 'QUAN' OR p_sfcat-datatype EQ 'CURR'.
p_sfcat-just = 'R'.
ENDIF.
p_sfcat-seltext = p_sfcat-coltext.
APPEND p_sfcat TO p_tfcat.
CLEAR : p_sfcat.
ENDIF.
ENDFORM. " FILL_FCAT_X01
*&---------------------------------------------------------------------*
*& Form GET_LIKEITAB_FACT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_P_ITAB_NAME text
* -->P_P_STRUCTURE_NAME text
* -->P_P_RFCAT text
*----------------------------------------------------------------------*
FORM get_likeitab_fact USING p_likeitab_name
p_ddic_fcat TYPE lvc_t_fcat.
DATA : lt_table LIKE dd02l-tabname OCCURS 0 WITH HEADER LINE.
DATA : lt_fieldcat TYPE slis_t_fieldcat_alv.
DATA : lt_alv_cat TYPE TABLE OF lvc_s_fcat.
DATA : l_alv_cat TYPE lvc_s_fcat.
CLEAR : p_ddic_fcat[], p_ddic_fcat.
CLEAR : lt_table[], lt_table.
CLEAR : lt_fieldcat[], lt_fieldcat.
CLEAR : lt_alv_cat[], lt_alv_cat.
* "Internal Table을 참조하여 Field Catalog 정보를 구성한다.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = sy-repid
i_internal_tabname = p_likeitab_name
i_inclname = sy-repid
* I_STRUCTURE_NAME = P_STRUCTURE_NAME
i_bypassing_buffer = 'X'
* I_BUFFER_ACTIVE = 'X'
CHANGING
ct_fieldcat = lt_fieldcat[]
EXCEPTIONS
inconsistent_interface = 1
program_error = 2.
CALL FUNCTION 'LVC_TRANSFER_FROM_SLIS'
EXPORTING
it_fieldcat_alv = lt_fieldcat
IMPORTING
et_fieldcat_lvc = lt_alv_cat
TABLES
it_data = lt_table[].
CALL FUNCTION 'LVC_FIELDCAT_COMPLETE'
CHANGING
ct_fieldcat = lt_alv_cat.
CLEAR : p_ddic_fcat, p_ddic_fcat[].
LOOP AT lt_alv_cat INTO l_alv_cat WHERE no_out = 'X'.
CLEAR : l_alv_cat-no_out.
MODIFY lt_alv_cat FROM l_alv_cat INDEX sy-tabix.
ENDLOOP.
p_ddic_fcat[] = lt_alv_cat[].
CLEAR : lt_alv_cat, lt_alv_cat[].
ENDFORM. " GET_LIKEITAB_FACT
*&---------------------------------------------------------------------*
*& Form SET_TOP_OF_PAGE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_GO_CONTAINER_TOP1 text
* -->P_GO_ALV1 text
* -->P_GO_DD_DOCUMENT1 text
* -->P_GO_HTML_VIEW1 text
*----------------------------------------------------------------------*
FORM set_top_of_page USING
p_top_cont TYPE REF TO cl_gui_container
p_grid TYPE REF TO lcl_def_grid
p_doc TYPE REF TO cl_dd_document
p_html TYPE REF TO cl_gui_html_viewer.
DATA : dl_length TYPE i. " Length
DATA : dl_background_id TYPE sdydo_key VALUE 'ALV_BACKGROUND'.
DATA : l_alv_grid TYPE sdydo_attribute VALUE 'CL_GUI_ALV_GRID'.
IF p_doc IS INITIAL.
CREATE OBJECT p_doc
EXPORTING
style = l_alv_grid.
ENDIF.
CALL METHOD p_doc->initialize_document.
CALL METHOD p_grid->list_processing_events
EXPORTING
i_event_name = 'TOP_OF_PAGE'
i_dyndoc_id = p_doc.
*CREATING HTML CONTROL
IF p_html IS INITIAL.
CREATE OBJECT p_html
EXPORTING
parent = p_top_cont.
ENDIF.
* REUSE_ALV_GRID_COMMENTARY_SET
CALL FUNCTION 'REUSE_ALV_GRID_COMMENTARY_SET'
EXPORTING
document = p_doc
bottom = space
IMPORTING
length = dl_length.
* GET TOP->HTML_TABLE READY
CALL METHOD p_doc->merge_document.
* Set wallpaper
CALL METHOD p_doc->set_document_background
EXPORTING
picture_id = dl_background_id.
PERFORM set_top_of_page_text USING p_doc.
* Connect TOP document to HTML-Control
p_doc->html_control = p_html.
* Display TOP document
CALL METHOD p_doc->display_document
EXPORTING
reuse_control = 'X'
parent = p_top_cont
EXCEPTIONS
html_display_error = 1.
ENDFORM. " SET_TOP_OF_PAGE
*&---------------------------------------------------------------------*
*& Form SET_TOP_OF_PAGE_TEXT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM set_top_of_page_text USING
p_doc TYPE REF TO cl_dd_document.
LOOP AT gt_top_of_page_txt.
CALL METHOD p_doc->add_text
EXPORTING
text = gt_top_of_page_txt-top_text
sap_fontsize = gt_top_of_page_txt-fontsize
sap_color = gt_top_of_page_txt-color.
CALL METHOD p_doc->new_line.
ENDLOOP.
ENDFORM. " SET_TOP_OF_PAGE_TEXT
*& Include ZEVR0010C01
*&---------------------------------------------------------------------*
*******************************
* LOCAL CLASSES: DEFINITION
*******************************
* 클래스 정의
CLASS lcl_def_receiver DEFINITION.
PUBLIC SECTION.
METHODS: handle_top_of_page
FOR EVENT top_of_page OF cl_gui_alv_grid
IMPORTING e_dyndoc_id table_index.
METHODS : handle_toolbar
FOR EVENT toolbar OF cl_gui_alv_grid
IMPORTING sender
e_object
e_interactive.
METHODS : handle_user_command
FOR EVENT user_command OF cl_gui_alv_grid
IMPORTING sender e_ucomm.
METHODS : handle_data_changed
FOR EVENT data_changed OF cl_gui_alv_grid
IMPORTING sender er_data_changed.
METHODS : handle_after_user_command
FOR EVENT after_user_command OF cl_gui_alv_grid.
METHODS : handle_data_changed_finished
FOR EVENT data_changed_finished OF cl_gui_alv_grid
IMPORTING sender e_modified
et_good_cells.
METHODS : handle_hotspot_click
FOR EVENT hotspot_click OF cl_gui_alv_grid
IMPORTING sender e_row_id
e_column_id.
METHODS : handle_double_click
FOR EVENT double_click OF cl_gui_alv_grid
IMPORTING sender
e_row
e_column
es_row_no.
METHODS: handle_on_f4 FOR EVENT onf4 OF cl_gui_alv_grid
IMPORTING sender
e_fieldname
e_fieldvalue
es_row_no
er_event_data
et_bad_cells
e_display.
ENDCLASS. " LCL_DEF_RECEIVER
*******************************
* LOCAL CLASSES: IMPLEMENTATION
*******************************
* 클래스 구현
CLASS lcl_def_receiver IMPLEMENTATION.
METHOD handle_top_of_page.
* PERFORM top_of_page USING e_dyndoc_id table_index.
ENDMETHOD. "HANDLE_TOP_OF_PAGE
METHOD handle_toolbar.
IF sender = go_alv1.
* PERFORM TOOBAR_PART USING SENDER E_OBJECT E_INTERACTIVE.
ENDIF.
ENDMETHOD. "handle_toolbar
*----------------------------------------------------------------------*
* CLASS LCL_EVENT_RECEIVER IMPLEMENTATION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
METHOD handle_after_user_command.
* PERFORM AFTER_USER_COMMAND.
ENDMETHOD. "HANDLE_AFTER_USER_COMMAND
METHOD handle_user_command.
IF sender = go_alv1.
PERFORM user_command_part USING e_ucomm.
ENDIF.
ENDMETHOD. "handle_user_command
METHOD handle_data_changed.
IF sender = go_alv1.
PERFORM data_changed USING er_data_changed.
ENDIF.
ENDMETHOD. "handle_data_changed
METHOD handle_data_changed_finished.
IF sender = go_alv1.
PERFORM data_changed_finished USING e_modified et_good_cells.
ENDIF.
ENDMETHOD. "handle_data_changed_finished
METHOD handle_hotspot_click.
IF sender = go_alv1.
PERFORM hotspot_click USING e_row_id e_column_id.
ENDIF.
ENDMETHOD. "handle_hotspot_click
METHOD handle_double_click.
IF sender = go_alv1.
PERFORM double_click USING e_row e_column es_row_no.
ENDIF.
ENDMETHOD. "handle_double_click
METHOD handle_on_f4.
PERFORM on_f4 USING sender
e_fieldname
e_fieldvalue
es_row_no
er_event_data
et_bad_cells
e_display.
ENDMETHOD. "handle_on_f4
ENDCLASS. " LCL_DEF_RECEIVER
*&---------------------------------------------------------------------*
*& FORM TOOBAR_PART
*&---------------------------------------------------------------------*
* TOOBAR_PART
*----------------------------------------------------------------------*
FORM toobar_part USING sender
p_c_object TYPE REF TO cl_alv_event_toolbar_set
p_interactive.
* PERFORM TOOBAR_PART_100 USING P_C_OBJECT P_INTERACTIVE.
ENDFORM. " TOOBAR_PART
*&---------------------------------------------------------------------*
*& FORM USER_COMMAND_PART
*&---------------------------------------------------------------------*
* TEXT
*----------------------------------------------------------------------*
* -->P_E_UCOMM TEXT
*----------------------------------------------------------------------*
FORM user_command_part USING p_ucomm.
IF p_ucomm EQ 'SUB'.
PERFORM get_selected_row USING go_alv1.
PERFORM user_command.
ENDIF.
ENDFORM. " USER_COMMAND_PART
*&---------------------------------------------------------------------*
*& FORM DATA_CHANGED
*&---------------------------------------------------------------------*
* TEXT
*----------------------------------------------------------------------*
* -->P_ER_DATA_CHANGED TEXT
*----------------------------------------------------------------------*
FORM data_changed USING p_c_data_changed
TYPE REF TO cl_alv_changed_data_protocol.
ENDFORM. " DATA_CHANGED
*&---------------------------------------------------------------------*
*& Form F_OUT_MESSAGE_PROC
*&---------------------------------------------------------------------*
* 에러처리를 한다.
*----------------------------------------------------------------------*
* -->P_DATA_CHANGED text
* -->P_MODF_FIELD text
*----------------------------------------------------------------------*
FORM f_out_message_proc
USING p_data_changed TYPE REF TO cl_alv_changed_data_protocol
p_modf_field TYPE lvc_s_modi
ps_msg TYPE t_msg.
* CALL METHOD P_DATA_CHANGED->ADD_PROTOCOL_ENTRY
* EXPORTING
* I_MSGID = PS_MSG-MSGID
* I_MSGTY = PS_MSG-MSGTY
* I_MSGNO = PS_MSG-MSGNO
* I_MSGV1 = PS_MSG-MSG1
* I_MSGV2 = PS_MSG-MSG2
* I_MSGV3 = PS_MSG-MSG3
* I_MSGV4 = PS_MSG-MSG4
* I_FIELDNAME = P_MODF_FIELD-FIELDNAME
* I_ROW_ID = P_MODF_FIELD-ROW_ID.
ENDFORM. " F_OUT_MESSAGE_PROC
*&---------------------------------------------------------------------*
*& FORM DATA_CHANGED_FINISHED
*&---------------------------------------------------------------------*
* TEXT
*----------------------------------------------------------------------*
* -->P_E_MODIFIED TEXT
* -->P_ET_GOOD_CELLS TEXT
*----------------------------------------------------------------------*
FORM data_changed_finished USING p_e_modified
et_good_cells. " TYPE LVC_T_MODI
ENDFORM. " DATA_CHANGED_FINISHED
*&---------------------------------------------------------------------*
*& FORM HOTSPOT_CLICK
*&---------------------------------------------------------------------*
* TEXT
*----------------------------------------------------------------------*
* -->P_E_ROW_ID TEXT
* -->P_E_COLUMN_ID TEXT
*----------------------------------------------------------------------*
FORM hotspot_click USING p_row_id
p_column_id.
IF p_column_id EQ 'BELNR'.
IF p_sel01 EQ 'X'.
CLEAR gs_card.
READ TABLE gt_card INTO gs_card INDEX p_row_id.
CHECK sy-subrc EQ 0.
ELSEIF p_sel02 EQ 'X'.
CLEAR gs_dti.
READ TABLE gt_dti INTO gs_dti INDEX p_row_id.
CHECK sy-subrc EQ 0.
ELSEIF p_sel03 EQ 'X'.
CLEAR gs_etc.
READ TABLE gt_etc INTO gs_etc INDEX p_row_id.
CHECK sy-subrc EQ 0.
ENDIF.
ENDIF.
ENDFORM. " HOTSPOT_CLICK
*&---------------------------------------------------------------------*
*& FORM DOUBLE_CLICK
*&---------------------------------------------------------------------*
* TEXT
*----------------------------------------------------------------------*
* -->P_E_ROW TEXT
* -->P_E_COLUMN TEXT
* -->P_ES_ROW_NO TEXT
*----------------------------------------------------------------------*
FORM double_click USING p_row TYPE lvc_s_row
p_column
p_s_row_no.
RANGES : lr_cardno FOR ztficd10-zcardno,
lr_mail FOR zdti_header-zbyre,
lr_supno FOR zdti_header-supno,
lr_pernr FOR usr02-bname.
CHECK p_row-index NE 0.
IF p_sel01 EQ 'X'.
CLEAR gs_card.
READ TABLE gt_card INTO gs_card INDEX p_row-index.
add_range_eq_space : lr_cardno gs_card-zcardno.
ELSEIF p_sel02 EQ 'X'.
CLEAR gs_dti.
READ TABLE gt_dti INTO gs_dti INDEX p_row-index.
add_range_eq_space : lr_mail gs_dti-email,
lr_supno gs_dti-supno.
ELSEIF p_sel03 EQ 'X'.
CLEAR gs_etc.
READ TABLE gt_etc INTO gs_etc INDEX p_row-index.
add_range_eq_space : lr_pernr gs_etc-empno.
ENDIF.
SUBMIT zevr0020 USING SELECTION-SCREEN 1000
WITH p_bukrs EQ p_bukrs
WITH s_budat IN s_budat
WITH p_sel01 EQ p_sel01
WITH p_sel02 EQ p_sel02
WITH p_sel03 EQ p_sel03
WITH p_tot EQ p_tot
WITH p_fi EQ p_fi
WITH p_tr EQ p_tr
WITH s_cardno IN lr_cardno
WITH s_mail IN lr_mail
WITH s_supno IN lr_supno
WITH s_pernr IN lr_pernr
AND RETURN.
ENDFORM. " DOUBLE_CLICK
*&---------------------------------------------------------------------*
*& Form ON_F4
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_SENDER text
* -->P_E_FIELDNAME text
* -->P_E_FIELDVALUE text
* -->P_ES_ROW_NO text
* -->P_ER_EVENT_DATA text
* -->P_ET_BAD_CELLS text
* -->P_E_DISPLAY text
*----------------------------------------------------------------------*
FORM on_f4 USING p_c_sender TYPE REF TO cl_gui_alv_grid
p_fieldname TYPE lvc_fname
p_fieldvalue TYPE lvc_value
p_s_row_no TYPE lvc_s_roid
p_c_event_data TYPE REF TO cl_alv_event_data
p_t_bad_cells TYPE lvc_t_modi
p_display TYPE char01.
* PERFORM ON_F4_100 USING P_C_SENDER
* P_FIELDNAME
* P_FIELDVALUE
* P_S_ROW_NO
* P_C_EVENT_DATA
* P_T_BAD_CELLS
* P_DISPLAY.
ENDFORM. " ON_F4
*&---------------------------------------------------------------------*
*& Form ON_F4_100
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_P_C_SENDER text
* -->P_P_FIELDNAME text
* -->P_P_FIELDVALUE text
* -->P_P_S_ROW_NO text
* -->P_P_C_EVENT_DATA text
* -->P_P_T_BAD_CELLS text
* -->P_P_DISPLAY text
*----------------------------------------------------------------------*
*FORM ON_F4_100 USING P_C_SENDER TYPE REF TO CL_GUI_ALV_GRID
* P_FIELDNAME TYPE LVC_FNAME
* P_FIELDVALUE TYPE LVC_VALUE
* P_S_ROW_NO TYPE LVC_S_ROID
* P_C_EVENT_DATA TYPE REF TO CL_ALV_EVENT_DATA
* P_T_BAD_CELLS TYPE LVC_T_MODI
* P_DISPLAY TYPE CHAR01.
*
* DATA : LT_RETURN LIKE DDSHRETVAL OCCURS 0 WITH HEADER LINE.
* DATA : LS_LVC_MODI TYPE LVC_S_MODI.
*
* FIELD-SYMBOLS : <FS_DATA> TYPE LVC_T_MODI.
* CLEAR : P_DISPLAY .
*
* CASE P_FIELDNAME.
* WHEN 'MEINS'.
* ENDCASE.
*
*ENDFORM. " ON_F4_100
*&---------------------------------------------------------------------*
*& Form SET_ALV_LIST
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_LCL_GRID text
* -->P_0062 text
* -->P_0063 text
*----------------------------------------------------------------------*
FORM display_alv_list USING pv_alv_grid TYPE REF TO lcl_def_grid
p_tname
p_cnt.
* 로컬변수선언
DATA : lv_table LIKE feld-name.
FIELD-SYMBOLS : <table> TYPE STANDARD TABLE,
<ft_fcat> TYPE STANDARD TABLE,
<ft_sort> TYPE STANDARD TABLE,
<ft_func> TYPE STANDARD TABLE,
<fs_layo> TYPE any.
DATA : l_subrc LIKE sy-subrc.
DATA : l_fieldname LIKE dd03l-fieldname.
CONCATENATE p_tname '[]' INTO lv_table.
ASSIGN (lv_table) TO <table>.
*-- TOOLBAR ASSIGN
CONCATENATE 'GT_UI_FUNCTIONS' p_cnt INTO lv_table.
ASSIGN (lv_table) TO <ft_func>.
*-- FIELDCAT ASSIGN
CONCATENATE 'GT_LVC_FCAT' p_cnt '[]' INTO lv_table.
ASSIGN (lv_table) TO <ft_fcat>.
*-- GT_LVC_SORT ASSIGN
CONCATENATE 'GT_LVC_SORT' p_cnt '[]' INTO lv_table.
ASSIGN (lv_table) TO <ft_sort>.
PERFORM check_sort_parameter USING <ft_fcat>[] <ft_sort>[]
CHANGING l_fieldname l_subrc.
IF l_subrc NE 0.
CONCATENATE l_fieldname ` : `
`Not Exist SORT Field` INTO l_fieldname.
MESSAGE s000 DISPLAY LIKE 'E' WITH l_fieldname.
EXIT.
ENDIF.
CONCATENATE 'GS_LVC_LAYO' p_cnt INTO lv_table.
ASSIGN (lv_table) TO <fs_layo>.
SORT <table>.
CHECK NOT pv_alv_grid IS INITIAL.
* gv_consistency_check = 'X'.
CALL METHOD pv_alv_grid->set_table_for_first_display
EXPORTING
is_variant = gs_variant
i_save = 'A'
i_default = 'X'
is_layout = <fs_layo>
i_consistency_check = gv_consistency_check
it_toolbar_excluding = <ft_func>
CHANGING
it_outtab = <table>
it_fieldcatalog = <ft_fcat>
it_sort = <ft_sort>
EXCEPTIONS
invalid_parameter_combination = 1
program_error = 2
too_many_lines = 3
OTHERS = 4.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDFORM. " SET_ALV_LIST
*&---------------------------------------------------------------------*
*& Form SET_FIELDCATALOG_MERGE_X01
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_C_STRUC text
* <--P_GT_LVC_FCAT1 text
*----------------------------------------------------------------------*
FORM set_fcat_ddic_x01
USING p_strnam LIKE dd02l-tabname
CHANGING p_t_lvc_fcat TYPE lvc_t_fcat.
DATA : ls_lvc_fcat TYPE lvc_s_fcat.
DATA : lt_dd03t TYPE TABLE OF dd03t WITH HEADER LINE.
CLEAR: p_t_lvc_fcat, p_t_lvc_fcat[], ls_lvc_fcat.
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
i_structure_name = p_strnam
i_bypassing_buffer = 'X'
CHANGING
ct_fieldcat = p_t_lvc_fcat
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
*-- 사용자 정의 구조 추가
* PERFORM FILL_FIELD_CATALOGS TABLES P_T_LVC_FCAT USING:
* 'S' 'FIELDNAME' 'STATUS',
* ' ' 'KEY' 'X',
* ' ' 'JUST' 'C',
* ' ' 'OUTPUTLEN' '3',
* ' ' 'ICON' 'X',
* ' ' 'COL_POS' '1',
* ' ' 'REF_TABLE' 'ICON',
* ' ' 'REF_FIELD' 'ID',
* 'E' 'SCRTEXT_L' 'STATUS',
*
* 'S' 'FIELDNAME' 'MESSAGE',
* ' ' 'JUST' 'L',
* ' ' 'OUTPUTLEN' '60',
* ' ' 'COL_POS' '90',
* ' ' 'DATATYPE' 'CHAR',
* ' ' 'INTLEN' '255',
* 'E' 'SCRTEXT_L' 'MESSAGE'.
LOOP AT p_t_lvc_fcat INTO ls_lvc_fcat.
*-- 숫자는 오른쪽 정렬
IF ls_lvc_fcat-datatype EQ 'DEC' OR ls_lvc_fcat-datatype CP 'INT+'
OR ls_lvc_fcat-datatype EQ 'QUAN' OR ls_lvc_fcat-datatype EQ 'CURR'.
ls_lvc_fcat-just = 'R'.
ENDIF.
**-- 필드별 속성 재정의
* PERFORM FCAT_SCR_0100_X01 USING P_STRNAM
* CHANGING LS_LVC_FCAT.
*- 필드 텍스트 넣기
IF ls_lvc_fcat-scrtext_l IS NOT INITIAL.
ls_lvc_fcat-coltext = ls_lvc_fcat-scrtext_l.
ELSE.
ls_lvc_fcat-coltext = ls_lvc_fcat-reptext.
ENDIF.
ls_lvc_fcat-seltext = ls_lvc_fcat-coltext.
MODIFY p_t_lvc_fcat FROM ls_lvc_fcat.
ENDLOOP.
ENDFORM. " SET_FIELDCATALOG_MERGE_X01
*&---------------------------------------------------------------------*
*& Form FILL_FIELD_CATALOGS
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_T_LVC_FCAT text
* -->P_GUB text
* -->P_FNAME text
* -->P_VALUE text
*----------------------------------------------------------------------*
FORM fill_field_catalogs TABLES p_t_lvc_fcat TYPE lvc_t_fcat
USING p_gub p_fname p_value.
IF p_gub = 'S'.
CLEAR gs_lvc_fcat.
ENDIF.
DATA l_fname(40).
FIELD-SYMBOLS <fs> TYPE any.
CONCATENATE 'GS_LVC_FCAT-' p_fname INTO l_fname.
ASSIGN (l_fname) TO <fs>.
<fs> = p_value.
IF p_gub = 'E'.
APPEND gs_lvc_fcat TO p_t_lvc_fcat.
ENDIF.
ENDFORM. " FILL_FIELD_CATALOGS
*&---------------------------------------------------------------------*
*& Form FILL_FCAT_X01
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_&1 text
* -->P_&2 text
* -->P_&3 text
* -->P_P_SFCAT text
* -->P_P_TFCAT text
* -->P_P_RFCAT text
*----------------------------------------------------------------------*
FORM fill_fcat USING p_gub p_fname p_con
p_sfcat TYPE lvc_s_fcat
p_tfcat TYPE lvc_t_fcat
p_ref_fcat TYPE lvc_t_fcat.
DATA : ls_fcat TYPE lvc_s_fcat.
CLEAR : ls_fcat.
IF p_gub = 'S'. " 시작에서 담고 계속 돌면서..''E'를 만났을 때 APPEND해준다.
CLEAR p_sfcat.
READ TABLE p_ref_fcat INTO ls_fcat
WITH KEY fieldname = p_fname.
MOVE-CORRESPONDING ls_fcat TO p_sfcat.
p_sfcat-fieldname = p_fname.
"gt_fieldcat_h와 gs_fieldcat에서 Name이 다른 Field 정보를 넘겨준다.
p_sfcat-scrtext_l = ls_fcat-scrtext_l.
p_sfcat-scrtext_m = ls_fcat-scrtext_m.
p_sfcat-scrtext_s = ls_fcat-scrtext_s.
p_sfcat-reptext = ls_fcat-reptext.
p_sfcat-colddictxt = ls_fcat-colddictxt.
p_sfcat-ref_field = ls_fcat-ref_field.
p_sfcat-ref_table = ls_fcat-ref_table.
p_sfcat-roundfield = ls_fcat-roundfield.
p_sfcat-decmlfield = ls_fcat-decmlfield.
p_sfcat-decimals = ls_fcat-decimals.
EXIT.
ENDIF.
DATA : l_col(40).
FIELD-SYMBOLS : <fs>.
CONCATENATE 'GS_LVC_FCAT-' p_fname INTO l_col.
ASSIGN (l_col) TO <fs>.
MOVE p_con TO <fs>.
IF p_gub = 'E'.
IF p_sfcat-datatype = 'CURR'.
IF p_sfcat-cfieldname IS INITIAL
AND p_sfcat-currency IS INITIAL.
READ TABLE p_ref_fcat INTO ls_fcat
WITH KEY datatype = 'CUKY'.
IF sy-subrc EQ 0.
p_sfcat-cfieldname = ls_fcat-fieldname.
ELSE.
p_sfcat-currency = 'KRW'.
ENDIF.
ENDIF.
ENDIF.
IF p_sfcat-datatype = 'QUAN'.
IF p_sfcat-qfieldname IS INITIAL.
READ TABLE p_ref_fcat INTO ls_fcat
WITH KEY datatype = 'UNIT'.
IF sy-subrc EQ 0.
p_sfcat-qfieldname = ls_fcat-fieldname.
ENDIF.
ENDIF.
ENDIF.
gv_alv_colpos = gv_alv_colpos + 1.
p_sfcat-col_pos = gv_alv_colpos.
IF p_sfcat-outputlen IS INITIAL.
p_sfcat-outputlen = ls_fcat-intlen + 2.
ENDIF.
" 숫자형은 오른쪽 정렬.
IF p_sfcat-datatype EQ 'DEC' OR p_sfcat-datatype CP 'INT+'
OR p_sfcat-datatype EQ 'QUAN' OR p_sfcat-datatype EQ 'CURR'.
p_sfcat-just = 'R'.
ENDIF.
p_sfcat-seltext = p_sfcat-coltext.
APPEND p_sfcat TO p_tfcat.
CLEAR : p_sfcat.
ENDIF.
ENDFORM. " FILL_FCAT_X01
*&---------------------------------------------------------------------*
*& Form GET_LIKEITAB_FACT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_P_ITAB_NAME text
* -->P_P_STRUCTURE_NAME text
* -->P_P_RFCAT text
*----------------------------------------------------------------------*
FORM get_likeitab_fact USING p_likeitab_name
p_ddic_fcat TYPE lvc_t_fcat.
DATA : lt_table LIKE dd02l-tabname OCCURS 0 WITH HEADER LINE.
DATA : lt_fieldcat TYPE slis_t_fieldcat_alv.
DATA : lt_alv_cat TYPE TABLE OF lvc_s_fcat.
DATA : l_alv_cat TYPE lvc_s_fcat.
CLEAR : p_ddic_fcat[], p_ddic_fcat.
CLEAR : lt_table[], lt_table.
CLEAR : lt_fieldcat[], lt_fieldcat.
CLEAR : lt_alv_cat[], lt_alv_cat.
* "Internal Table을 참조하여 Field Catalog 정보를 구성한다.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = sy-repid
i_internal_tabname = p_likeitab_name
i_inclname = sy-repid
* I_STRUCTURE_NAME = P_STRUCTURE_NAME
i_bypassing_buffer = 'X'
* I_BUFFER_ACTIVE = 'X'
CHANGING
ct_fieldcat = lt_fieldcat[]
EXCEPTIONS
inconsistent_interface = 1
program_error = 2.
CALL FUNCTION 'LVC_TRANSFER_FROM_SLIS'
EXPORTING
it_fieldcat_alv = lt_fieldcat
IMPORTING
et_fieldcat_lvc = lt_alv_cat
TABLES
it_data = lt_table[].
CALL FUNCTION 'LVC_FIELDCAT_COMPLETE'
CHANGING
ct_fieldcat = lt_alv_cat.
CLEAR : p_ddic_fcat, p_ddic_fcat[].
LOOP AT lt_alv_cat INTO l_alv_cat WHERE no_out = 'X'.
CLEAR : l_alv_cat-no_out.
MODIFY lt_alv_cat FROM l_alv_cat INDEX sy-tabix.
ENDLOOP.
p_ddic_fcat[] = lt_alv_cat[].
CLEAR : lt_alv_cat, lt_alv_cat[].
ENDFORM. " GET_LIKEITAB_FACT
*&---------------------------------------------------------------------*
*& Form SET_TOP_OF_PAGE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_GO_CONTAINER_TOP1 text
* -->P_GO_ALV1 text
* -->P_GO_DD_DOCUMENT1 text
* -->P_GO_HTML_VIEW1 text
*----------------------------------------------------------------------*
FORM set_top_of_page USING
p_top_cont TYPE REF TO cl_gui_container
p_grid TYPE REF TO lcl_def_grid
p_doc TYPE REF TO cl_dd_document
p_html TYPE REF TO cl_gui_html_viewer.
DATA : dl_length TYPE i. " Length
DATA : dl_background_id TYPE sdydo_key VALUE 'ALV_BACKGROUND'.
DATA : l_alv_grid TYPE sdydo_attribute VALUE 'CL_GUI_ALV_GRID'.
IF p_doc IS INITIAL.
CREATE OBJECT p_doc
EXPORTING
style = l_alv_grid.
ENDIF.
CALL METHOD p_doc->initialize_document.
CALL METHOD p_grid->list_processing_events
EXPORTING
i_event_name = 'TOP_OF_PAGE'
i_dyndoc_id = p_doc.
*CREATING HTML CONTROL
IF p_html IS INITIAL.
CREATE OBJECT p_html
EXPORTING
parent = p_top_cont.
ENDIF.
* REUSE_ALV_GRID_COMMENTARY_SET
CALL FUNCTION 'REUSE_ALV_GRID_COMMENTARY_SET'
EXPORTING
document = p_doc
bottom = space
IMPORTING
length = dl_length.
* GET TOP->HTML_TABLE READY
CALL METHOD p_doc->merge_document.
* Set wallpaper
CALL METHOD p_doc->set_document_background
EXPORTING
picture_id = dl_background_id.
PERFORM set_top_of_page_text USING p_doc.
* Connect TOP document to HTML-Control
p_doc->html_control = p_html.
* Display TOP document
CALL METHOD p_doc->display_document
EXPORTING
reuse_control = 'X'
parent = p_top_cont
EXCEPTIONS
html_display_error = 1.
ENDFORM. " SET_TOP_OF_PAGE
*&---------------------------------------------------------------------*
*& Form SET_TOP_OF_PAGE_TEXT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM set_top_of_page_text USING
p_doc TYPE REF TO cl_dd_document.
LOOP AT gt_top_of_page_txt.
CALL METHOD p_doc->add_text
EXPORTING
text = gt_top_of_page_txt-top_text
sap_fontsize = gt_top_of_page_txt-fontsize
sap_color = gt_top_of_page_txt-color.
CALL METHOD p_doc->new_line.
ENDLOOP.
ENDFORM. " SET_TOP_OF_PAGE_TEXT
템플릿 - Z_COMMON
*&---------------------------------------------------------------------*
*& Include ZFI_COMMON
*&---------------------------------------------------------------------*
********************************************************
* 공통변수
********************************************************
TABLES: bdcmsgcoll, "* Collecting messages in the SAP System
alsmex_tabline, "* Rows for Table with Excel Data
tbtco, "* Job status overview table
rfcdoc,
rfcdes,
dbcon,
stxh.
TYPE-POOLS: kcde, vrm, icon, scp1, gseth, slis.
" Progress bar Message
DATA : gv_calc_i TYPE i. "* %
DATA : gv_progress_msg(100). "* Display
DATA : gv_calc_c0(5).
DATA : gv_calc_c1(5).
" group select
DATA : gv_value_set TYPE gseth_val_line.
DATA : gt_value_set TYPE gseth_val_tab.
DATA : gt_detmsg TYPE TABLE OF scp1_general_error.
DATA : gt_heamsg TYPE TABLE OF scp1_general_error.
"도메인 가져오기
DATA : BEGIN OF gs_domain,
domain LIKE dd07t-domname,
value LIKE dd07t-domvalue_l,
ddtext LIKE dd07t-ddtext,
END OF gs_domain.
DATA : gt_domain LIKE TABLE OF gs_domain.
" 엑셀 내보내기용
TYPES : BEGIN OF t_excel_export,
excel_col TYPE string,
END OF t_excel_export.
DATA : gt_excel_export TYPE t_excel_export OCCURS 0 WITH HEADER LINE.
" 조회 권한
*-- 'X'일때에는 조회만 가능
DATA : gv_dip_mod TYPE c.
*-------------------------------------------------
* Company Code 정보.
*-------------------------------------------------
DATA : gv_butxt_cm TYPE t001-butxt VALUE ''.
DATA : gv_kokrs_txt TYPE tkt09-txt VALUE ''.
DATA : gv_waers_cm TYPE t001-waers VALUE ''.
DATA : gv_ktopl_cm TYPE t001-ktopl VALUE ''.
DATA : gv_spras_cm TYPE t001-spras VALUE ''. " KO
DATA : gv_land1_cm TYPE t001-land1 VALUE ''.
DATA : gv_kbezei_cm LIKE tka01-bezei VALUE ''. "
*-----------------------------------------------
* BDC DEFINITION
* ----------------------------------------------
DATA: gs_bdc_option TYPE ctu_params.
DATA: gt_bdcdata LIKE bdcdata OCCURS 0 WITH HEADER LINE.
DATA: gt_messtab LIKE bdcmsgcoll OCCURS 0 WITH HEADER LINE.
****************************************
* POSTING_INTERFACE_DOCUMENT.
****************************************
DATA : ftpost LIKE ftpost OCCURS 0 WITH HEADER LINE.
DATA : fttax LIKE fttax OCCURS 0 WITH HEADER LINE.
DATA : blntab LIKE blntab OCCURS 0 WITH HEADER LINE.
DATA : gv_ftpost_type TYPE c.
DATA : gv_ftpost_cnt TYPE i.
DATA : gv_ftpost_waers LIKE t001-waers.
DATA : BEGIN OF gt_if_msg OCCURS 0,
msgid LIKE sy-msgid,
msgno LIKE sy-msgno,
msgty LIKE sy-msgty,
msgv1 LIKE sy-msgv1,
msgv2 LIKE sy-msgv2,
msgv3 LIKE sy-msgv3,
msgv4 LIKE sy-msgv4,
subrc LIKE sy-subrc,
message LIKE bdcmsgcoll-msgv1,
END OF gt_if_msg.
****************************************
" 값이 없으면 BDC를 태우지 않음.
DATA : BEGIN OF gt_excp_init_field OCCURS 0,
fname TYPE fnam_____4,
END OF gt_excp_init_field.
********************************************************
* 매크로
********************************************************
*-----------------------------------------------
* MACRO DEFINITION
* ----------------------------------------------
"SETNODE 내역을 RANGE 변수에 INSERT.
DEFINE macro_value_to_range.
CLEAR : gv_value_set.
CLEAR : &1. REFRESH : &1.
LOOP AT &2 INTO gv_value_set.
&1-low = gv_value_set-vfrom.
&1-sign = 'I'.
IF gv_value_set-vfrom NE gv_value_set-vto.
&1-option = 'BT'.
&1-high = gv_value_set-vto.
ELSE.
&1-option = 'EQ'.
ENDIF.
APPEND &1.
CLEAR : &1.
ENDLOOP.
CLEAR : &2. REFRESH : &2.
END-OF-DEFINITION.
DEFINE add_range_eq.
IF &2 NE space.
CLEAR &1.
&1-sign = 'I'.
&1-option = 'EQ'.
&1-low = &2.
APPEND &1.
ENDIF.
END-OF-DEFINITION.
DEFINE add_range_full.
CLEAR &1.
&1-sign = &2.
&1-option = &3.
&1-low = &4.
&1-high = &5.
APPEND &1.
END-OF-DEFINITION.
*&---------------------------------------------------------------------*
*& Form ADD_EXCP_FIELD_WHEN_INITIAL
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_FIELD text
*----------------------------------------------------------------------*
FORM add_excp_field_when_initial USING p_field.
DATA : l_excp_field LIKE LINE OF gt_excp_init_field.
CLEAR : l_excp_field.
l_excp_field-fname = p_field.
APPEND l_excp_field TO gt_excp_init_field.
ENDFORM. "ADD_EXCP_FIELD_WHEN_INITIAL
*&---------------------------------------------------------------------*
*& Form GET_INFO_LIKE_ITAB
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->PT_REF_FCAT text
* -->P_ITAB_NAME text
*----------------------------------------------------------------------*
FORM get_fcat_like_itab
TABLES pt_ref_fcat STRUCTURE lvc_s_fcat
USING p_itab_name TYPE dd03l-tabname.
DATA : lt_table LIKE dd02l-tabname OCCURS 0 WITH HEADER LINE.
DATA : lt_fieldcat TYPE slis_t_fieldcat_alv.
DATA : lt_alv_cat TYPE TABLE OF lvc_s_fcat.
CLEAR : lt_table, lt_table[].
CLEAR : lt_fieldcat, lt_fieldcat[].
CLEAR : lt_alv_cat, lt_alv_cat[].
"Internal Table 데이터 구성-> Fieldcat mege로 부터
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = sy-repid
i_internal_tabname = p_itab_name
i_inclname = sy-repid
i_structure_name = ''
i_bypassing_buffer = 'X'
CHANGING
ct_fieldcat = lt_fieldcat[]
EXCEPTIONS
inconsistent_interface = 1
program_error = 2.
CALL FUNCTION 'LVC_TRANSFER_FROM_SLIS'
EXPORTING
it_fieldcat_alv = lt_fieldcat
IMPORTING
et_fieldcat_lvc = lt_alv_cat
TABLES
it_data = lt_table[].
CALL FUNCTION 'LVC_FIELDCAT_COMPLETE'
CHANGING
ct_fieldcat = lt_alv_cat.
pt_ref_fcat[] = lt_alv_cat[].
CLEAR : lt_alv_cat, lt_alv_cat[].
ENDFORM. " GET_DD03_FCAT
*&---------------------------------------------------------------------*
*& Form SET_COMPANY_BASE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM set_company_base USING p_bukrs.
DATA : l_t001 LIKE t001.
CLEAR : l_t001.
SELECT SINGLE *
FROM t001
INTO l_t001
WHERE bukrs = p_bukrs.
IF sy-subrc EQ 0.
gv_waers_cm = l_t001-waers.
gv_ktopl_cm = l_t001-ktopl.
gv_spras_cm = l_t001-spras.
gv_butxt_cm = l_t001-butxt.
gv_land1_cm = l_t001-land1.
ENDIF.
ENDFORM. " SET_COMPANY_BASE
*PERFORM GET_SETLEAF_VALUES USING
* 'BUDGET' '0102'. =>1. GT_VALUE_SET에 값이 담김.
* MACRO_VALUE_TO_RANGE : => 2. 넘겨준 RANGE 변수에 값이 담김
* GR_BUDGET_KSTAR => 로컬 변수
* GT_VALUE_SET. => 매크로 이후 메모리에서 제거됨.
FORM get_setleaf_values
USING p_kokrs p_setname TYPE any
pv_class TYPE sethier-setclass.
DATA : lt_node TYPE gseth_node_tab.
DATA : l_class TYPE sethier-setclass.
DATA : l_setid TYPE sethier-setid.
DATA : lt_grphinfo TYPE grphinfo OCCURS 0 WITH HEADER LINE.
DATA : l_message TYPE string.
CLEAR : lt_node, lt_node[].
CLEAR : l_class, l_setid.
CLEAR : lt_grphinfo, lt_grphinfo[].
CLEAR : gt_value_set, gt_value_set[].
CLEAR : l_message.
l_class = pv_class.
CASE pv_class.
WHEN '0101'. " 코스트센터
CONCATENATE pv_class p_kokrs p_setname INTO l_setid.
WHEN '0102'. " 원가요소
CONCATENATE pv_class gv_ktopl_cm p_setname INTO l_setid.
WHEN '0103'. " 오더
* CONCATENATE PV_CLASS GC_KOKRS P_SETNAME INTO L_SETID.
CONCATENATE pv_class p_setname INTO l_setid. " New GL/Segment
WHEN '0106'. " 손익센터
CONCATENATE pv_class p_kokrs p_setname INTO l_setid.
WHEN '0109'. " 계정과목
CONCATENATE pv_class gv_ktopl_cm p_setname INTO l_setid.
ENDCASE.
CALL FUNCTION 'K_HIERARCHY_TABLES_READ'
EXPORTING
e_class = l_class
e_setid = l_setid
e_kokrs = p_kokrs
e_mandt = sy-mandt
TABLES
t_nodes = lt_node
t_values = gt_value_set
CHANGING
c_info = lt_grphinfo
c_overwrite = sy-datar
EXCEPTIONS
no_controlling_area = 1
no_chart_of_account = 2
different_controlling_areas = 3
different_chart_of_accounts = 4
set_not_found = 5
illegal_field_replacement = 6
illegal_table_replacement = 7
fm_raise = 8
convert_error = 9
no_overwrite_standard_hier = 10
no_bukrs_for_kokrs = 11
OTHERS = 12.
IF sy-subrc <> 0.
* MESSAGE ID 'GS' TYPE 'E' NUMBER '004'
* WITH P_SETNAME INTO L_MESSAGE.
* MESSAGE S000(ZCOM1) DISPLAY LIKE 'E' WITH L_MESSAGE.
* LEAVE LIST-PROCESSING.
ENDIF.
ENDFORM. "GET_SET_VALUES
*&---------------------------------------------------------------------*
*& Form DYNPRO
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->PT_BDCTAB text
* -->PV_DYNBEGIN text
* -->PV_INPUT text
* -->PV_VALUE text
*----------------------------------------------------------------------*
FORM dynpro TABLES pt_bdctab
USING pv_dynbegin pv_input pv_value.
DATA : ls_bdctab TYPE bdcdata.
CLEAR : ls_bdctab.
IF pv_dynbegin = 'X'.
WRITE : pv_input TO ls_bdctab-program LEFT-JUSTIFIED.
WRITE : pv_value TO ls_bdctab-dynpro LEFT-JUSTIFIED.
WRITE : 'X' TO ls_bdctab-dynbegin LEFT-JUSTIFIED.
APPEND ls_bdctab TO pt_bdctab.
ELSE.
READ TABLE gt_excp_init_field TRANSPORTING NO FIELDS
WITH KEY fname = pv_input BINARY SEARCH.
IF sy-subrc EQ 0 AND pv_value IS INITIAL.
EXIT.
ENDIF.
WRITE : pv_input TO ls_bdctab-fnam LEFT-JUSTIFIED.
WRITE : pv_value TO ls_bdctab-fval LEFT-JUSTIFIED.
APPEND ls_bdctab TO pt_bdctab.
ENDIF.
ENDFORM. "SET_DYNPRO
*ZCOC9060 업데이트용 BDC
FORM dynpro_update TABLES pt_bdctab
USING pv_dynbegin pv_input pv_value.
DATA : ls_bdctab TYPE bdcdata.
DATA : string_type(4) TYPE c.
CLEAR : ls_bdctab.
IF pv_dynbegin = 'X'.
WRITE : pv_input TO ls_bdctab-program LEFT-JUSTIFIED.
WRITE : pv_value TO ls_bdctab-dynpro LEFT-JUSTIFIED.
WRITE : 'X' TO ls_bdctab-dynbegin LEFT-JUSTIFIED.
APPEND ls_bdctab TO pt_bdctab.
ELSE.
* READ TABLE GT_EXCP_INIT_FIELD TRANSPORTING NO FIELDS
* WITH KEY FNAME = PV_INPUT BINARY SEARCH.
IF pv_value IS INITIAL.
EXIT.
ENDIF.
CALL FUNCTION 'NUMERIC_CHECK'
EXPORTING
string_in = pv_value
IMPORTING
htype = string_type.
IF string_type = 'CHAR'.
IF pv_value = '@'.
WRITE : pv_input TO ls_bdctab-fnam LEFT-JUSTIFIED.
WRITE : '' TO ls_bdctab-fval LEFT-JUSTIFIED.
APPEND ls_bdctab TO pt_bdctab.
EXIT.
ENDIF.
ENDIF.
WRITE : pv_input TO ls_bdctab-fnam LEFT-JUSTIFIED.
WRITE : pv_value TO ls_bdctab-fval LEFT-JUSTIFIED.
APPEND ls_bdctab TO pt_bdctab.
ENDIF.
ENDFORM. "SET_DYNPRO
*&---------------------------------------------------------------------*
*& Form SET_BDC_OPTION
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->PV_DEFSIZE text
* -->PV_UPDMODE text
* -->PV_CATTMODE text
* -->PV_DISMODE text
* -->PV_RACCOMMIT text
* -->PV_NOBINPT text
* -->PS_CTU_PARAMS text
*----------------------------------------------------------------------*
FORM set_bdc_option
USING pv_defsize
pv_updmode
pv_cattmode
pv_dismode
pv_raccommit
pv_nobinpt
CHANGING ps_ctu_params STRUCTURE ctu_params.
ps_ctu_params-defsize = pv_defsize.
ps_ctu_params-updmode = pv_updmode.
ps_ctu_params-cattmode = pv_cattmode.
ps_ctu_params-dismode = pv_dismode.
ps_ctu_params-racommit = pv_raccommit.
ps_ctu_params-nobinpt = pv_nobinpt.
ps_ctu_params-defsize = pv_defsize.
ENDFORM. "SET_BDC_OPTION
*&---------------------------------------------------------------------*
*& Form ZERO_O
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_IN text
* -->P_OUT text
*----------------------------------------------------------------------*
FORM zero_o USING p_in p_out.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
EXPORTING
input = p_in
IMPORTING
output = p_out.
ENDFORM. "ZERO_O
*&---------------------------------------------------------------------*
*& Form ZERO_I
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_IN text
* -->P_OUT text
*----------------------------------------------------------------------*
FORM zero_i USING p_in p_out.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = p_in
IMPORTING
output = p_out.
ENDFORM. "ZERO_I
*&---------------------------------------------------------------------*
*& Form BAR_MSG
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_PER text
* -->VALUE(P_MSG) text
*----------------------------------------------------------------------*
FORM bar_msg USING p_per TYPE i VALUE(p_msg).
CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
EXPORTING
percentage = p_per
text = p_msg.
ENDFORM. "BAR_MSG
*&---------------------------------------------------------------------*
*& Form BAR_MSG_PER
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_TEXT text
* -->P_CNT1 text
* -->P_CNT2 text
*----------------------------------------------------------------------*
" P_CNT1 : 현재 COUNT
" P_CNT2 : 총 COUNT
*&---------------------------------------------------------------------*
*& Form BAR_MSG_PER
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_TEXT text
* -->P_CNT1 text
* -->P_CNT2 text
*----------------------------------------------------------------------*
FORM bar_msg_per USING p_text p_cnt1 p_cnt2.
DATA : l_ncnt1(5) TYPE n.
DATA : l_ncnt2(5) TYPE n.
CLEAR : l_ncnt1, l_ncnt2.
l_ncnt1 = p_cnt1.
l_ncnt2 = p_cnt2.
gv_calc_i = p_cnt1 * 100 / p_cnt2.
gv_calc_c0 = gv_calc_i.
IF l_ncnt1 IS INITIAL AND l_ncnt2 IS INITIAL.
gv_progress_msg = p_text.
ELSE.
CONCATENATE p_text '(' gv_calc_c0 '% )'
INTO gv_progress_msg SEPARATED BY space.
CONDENSE gv_progress_msg.
ENDIF.
CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
EXPORTING
percentage = gv_calc_i
text = gv_progress_msg.
ENDFORM. " process_bar
*&---------------------------------------------------------------------*
*& Form DISPLAY_SPOOL_BY_SALV
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->PT_TABLE text
*----------------------------------------------------------------------*
*FORM DISPLAY_SPOOL_BY_SALV TABLES PT_TABLE.
* DATA : GR_TABLE TYPE REF TO CL_SALV_TABLE.
** SORT GT_DISPLAY.
* CL_SALV_TABLE=>FACTORY(
* IMPORTING
* R_SALV_TABLE = GR_TABLE
* CHANGING
* T_TABLE = PT_TABLE[] ).
*
* GR_TABLE->DISPLAY( ).
*ENDFORM. "DISPLAY_SPOOL_BY_SALV
*&---------------------------------------------------------------------*
*& Form SET_FRONT_MINUS
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_NUM text
*----------------------------------------------------------------------*
FORM set_minus_front CHANGING p_num.
CALL FUNCTION 'CLOI_PUT_SIGN_IN_FRONT'
CHANGING
value = p_num.
ENDFORM. " SET_FRONT_MINUS
*&---------------------------------------------------------------------*
*& Form F4_FNAME
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_NAME text
*----------------------------------------------------------------------*
FORM f4_fname CHANGING p_name.
DATA: file_table TYPE filetable,
rc TYPE i,
filedat TYPE string.
CALL METHOD cl_gui_frontend_services=>file_open_dialog
EXPORTING
default_filename = space
initial_directory = 'C:\'
CHANGING
file_table = file_table
rc = rc
EXCEPTIONS
OTHERS = 1.
IF sy-subrc <> 0.
EXIT.
ENDIF.
READ TABLE file_table INDEX 1 INTO filedat.
CHECK NOT filedat IS INITIAL.
p_name = filedat.
ENDFORM. " FILE_UPLOAD
*&---------------------------------------------------------------------*
*& Form UPLOAD_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->PT_EXCEL_TABLE text
* -->PS_EXCEL_STRUC text
* -->PV_EXCEL_FILENAME text
* -->PV_BEGIN_COL text
* -->PV_BEGIN_ROW text
* -->PV_END_COL text
* -->PV_END_ROW text
*----------------------------------------------------------------------*
FORM upload_data USING pt_excel_table
ps_excel_struc
pv_excel_filename
pv_begin_col TYPE i
pv_begin_row TYPE i
pv_end_col TYPE i
pv_end_row TYPE i.
DATA : lt_intern LIKE alsmex_tabline OCCURS 0 WITH HEADER LINE.
FIELD-SYMBOLS : <l_fs01>,
<l_fs02> TYPE STANDARD TABLE,
<l_fs03>.
ASSIGN: (pt_excel_table) TO <l_fs02>,
(ps_excel_struc) TO <l_fs03>.
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
filename = pv_excel_filename
i_begin_col = pv_begin_col
i_begin_row = pv_begin_row
i_end_col = pv_end_col
i_end_row = pv_end_row
TABLES
intern = lt_intern
EXCEPTIONS
inconsistent_parameters = 1
upload_ole = 2
OTHERS = 3.
IF sy-subrc <> 0.
IF sy-msgid IS INITIAL.
MESSAGE i000 WITH 'No Selected File Exists or Too Long File path'.
LEAVE LIST-PROCESSING.
ELSE.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDIF.
LOOP AT lt_intern.
AT NEW row.
CLEAR : <l_fs03>.
ENDAT.
ASSIGN COMPONENT lt_intern-col OF STRUCTURE <l_fs03> TO <l_fs01>.
IF lt_intern-value CO '0123456789,.- '.
REPLACE ALL OCCURRENCES OF ',' IN lt_intern-value WITH ''.
ENDIF.
MOVE lt_intern-value TO <l_fs01>.
AT END OF row.
APPEND <l_fs03> TO <l_fs02>.
ENDAT.
ENDLOOP.
ENDFORM. " UPLOAD_DATA
*&---------------------------------------------------------------------*
*& Form BDC_DATE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_DATE text
*----------------------------------------------------------------------*
FORM bdc_date CHANGING p_date.
REPLACE ALL OCCURRENCES OF '.' IN p_date WITH ''.
REPLACE ALL OCCURRENCES OF '-' IN p_date WITH ''.
REPLACE ALL OCCURRENCES OF '/' IN p_date WITH ''.
ENDFORM. " CONVERT_TO_SAP_DATE
*&---------------------------------------------------------------------*
*& Form BDC_CURR
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_DMBTR text
*----------------------------------------------------------------------*
FORM bdc_curr CHANGING p_dmbtr.
REPLACE ALL OCCURRENCES OF ',' IN p_dmbtr WITH ''.
ENDFORM. " CONVERT_TO_DMBTR
*&---------------------------------------------------------------------*
*& Form BDC_CHECKBOX
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_VALUE text
*----------------------------------------------------------------------*
FORM bdc_checkbox USING p_value.
TRANSLATE p_value TO UPPER CASE.
ENDFORM. " BDC_CHECKBOX
*&---------------------------------------------------------------------*
*& Form BUILD_MESSAGE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->PS_MESSAGE text
* -->PV_TEXT text
*----------------------------------------------------------------------*
FORM build_message USING ps_message STRUCTURE bdcmsgcoll
CHANGING pv_text.
CLEAR pv_text.
CALL FUNCTION 'MESSAGE_TEXT_BUILD'
EXPORTING
msgid = ps_message-msgid
msgnr = ps_message-msgnr
msgv1 = ps_message-msgv1
msgv2 = ps_message-msgv2
msgv3 = ps_message-msgv3
msgv4 = ps_message-msgv4
IMPORTING
message_text_output = pv_text.
REPLACE ALL OCCURRENCES OF '&' IN pv_text WITH ''.
* CONCATENATE PS_MESSAGE-FLDNAME PV_TEXT
* INTO PV_TEXT SEPARATED BY SPACE.
ENDFORM. " MESSAGE_BUILD
*&---------------------------------------------------------------------*
*& Form BUILD_MESSAGE_BAPI
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->PS_MESSAGE text
* -->PV_TEXT text
*----------------------------------------------------------------------*
FORM build_message_bapi USING ps_message STRUCTURE bapiret2
CHANGING pv_text.
CLEAR pv_text.
CALL FUNCTION 'MESSAGE_TEXT_BUILD'
EXPORTING
msgid = ps_message-id
msgnr = ps_message-number
msgv1 = ps_message-message_v1
msgv2 = ps_message-message_v2
msgv3 = ps_message-message_v3
msgv4 = ps_message-message_v4
IMPORTING
message_text_output = pv_text.
REPLACE ALL OCCURRENCES OF '&' IN pv_text WITH ''.
* CONCATENATE PS_MESSAGE-FLDNAME PV_TEXT
* INTO PV_TEXT SEPARATED BY SPACE.
ENDFORM. " MESSAGE_BUILD
*&---------------------------------------------------------------------*
*& Form EXCEL_FORM_DOWNLOAD
*&---------------------------------------------------------------------*
* text0
*----------------------------------------------------------------------*
FORM excel_form_download TABLES pt_excel_export
STRUCTURE gt_excel_export.
DATA : lt_fcat TYPE TABLE OF lvc_s_fcat.
DATA : ls_fcat TYPE lvc_s_fcat.
DATA : l_cnt(2) TYPE n VALUE '01'.
DATA : l_colname(20) TYPE c.
DATA : l_size TYPE i.
DATA : lf_data TYPE REF TO data.
DATA : ll_data TYPE REF TO data.
DATA : l_usr_act TYPE i.
DATA : l_file_len TYPE i.
DATA : l_fname TYPE string.
DATA : l_ext_filename TYPE string.
DATA : l_fullpath TYPE string.
DATA : l_path TYPE string.
FIELD-SYMBOLS : <fs_table> TYPE STANDARD TABLE.
FIELD-SYMBOLS : <fs_line> TYPE any.
FIELD-SYMBOLS : <fs_col> TYPE any.
DEFINE add_excel_col.
CLEAR : l_colname.
l_size = strlen( &1 ) + 2.
CONCATENATE 'COL' l_cnt INTO l_colname.
ls_fcat-fieldname = l_colname.
ls_fcat-col_pos = l_cnt.
ls_fcat-coltext = &1.
ls_fcat-inttype = 'C'.
ls_fcat-intlen = l_size.
APPEND ls_fcat TO lt_fcat.
l_cnt = l_cnt + 1.
CLEAR : ls_fcat, l_colname.
CLEAR : l_size.
END-OF-DEFINITION.
CLEAR : l_fname, l_ext_filename, l_fullpath, l_path.
CLEAR : l_usr_act, l_file_len.
CLEAR : lt_fcat, lt_fcat[].
CLEAR : ls_fcat.
CHECK pt_excel_export[] IS NOT INITIAL.
LOOP AT pt_excel_export.
add_excel_col : pt_excel_export-excel_col.
ENDLOOP.
" 동적 테이블 생성
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = lt_fcat
IMPORTING
ep_table = lf_data.
ASSIGN lf_data->* TO <fs_table>.
" 테이블 라인 생성
CREATE DATA ll_data LIKE LINE OF <fs_table>.
ASSIGN ll_data->* TO <fs_line>.
" 템플릿 내용 단 한라인만 등록
LOOP AT lt_fcat INTO ls_fcat.
ASSIGN COMPONENT ls_fcat-col_pos
OF STRUCTURE <fs_line> TO <fs_col>.
IF sy-subrc EQ 0.
<fs_col> = ls_fcat-coltext. " COLTEXT 의 내용을 그대로.
ENDIF.
ENDLOOP.
" 테이블에 담기.
APPEND <fs_line> TO <fs_table>.
CHECK <fs_table> IS NOT INITIAL.
CONCATENATE sy-repid '_UploadForm.xls' INTO l_fname.
CALL METHOD cl_gui_frontend_services=>file_save_dialog
EXPORTING
default_extension = 'XLS'
default_file_name = l_fname
file_filter = '*.XLS'
CHANGING
filename = l_ext_filename
path = l_path
fullpath = l_fullpath
user_action = l_usr_act.
IF l_usr_act = '0'.
CALL METHOD cl_gui_frontend_services=>gui_download
EXPORTING
filename = l_fullpath
write_field_separator = 'X'
IMPORTING
filelength = l_file_len
CHANGING
data_tab = <fs_table>
EXCEPTIONS
file_write_error = 1
no_batch = 2
gui_refuse_filetransfer = 3
invalid_type = 4
no_authority = 5
unknown_error = 6
header_not_allowed = 7
separator_not_allowed = 8
filesize_not_allowed = 9
header_too_long = 10
dp_error_create = 11
dp_error_send = 12
dp_error_write = 13
unknown_dp_error = 14
access_denied = 15
dp_out_of_memory = 16
disk_full = 17
dp_timeout = 18
file_not_found = 19
dataprovider_exception = 20
control_flush_error = 21
OTHERS = 22.
IF sy-subrc = 0.
MESSAGE s000 WITH 'Success.'.
ELSE.
MESSAGE i000 WITH 'Failure'.
ENDIF.
ELSE.
MESSAGE i000 WITH 'Cancled'.
ENDIF.
ENDFORM. " EXCEL_FORM_DOWNLOAD
*&---------------------------------------------------------------------*
*& Form CONVERT_CURRENCY
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_BUDAT text
* -->P_FCURR text
* -->P_LCURR text
* -->P_FAMT text
* -->P_LAMT text
*----------------------------------------------------------------------*
FORM convert_currency USING p_budat p_fcurr p_lcurr
p_famt p_lamt.
IF p_fcurr = p_lcurr.
p_lamt = p_famt.
ELSE.
CALL FUNCTION 'CONVERT_TO_LOCAL_CURRENCY'
EXPORTING
client = sy-mandt
date = p_budat
foreign_currency = p_fcurr
foreign_amount = p_famt
local_currency = p_lcurr
IMPORTING
local_amount = p_lamt
EXCEPTIONS
no_rate_found = 01.
ENDIF.
ENDFORM. "CONVERT_CURRENCY
*&---------------------------------------------------------------------*
*& Form CONVERT_CHAR_TO_AMT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_VALUE text
* -->P_WAERS text
* -->P_AMT text
*----------------------------------------------------------------------*
FORM convert_char_to_amt USING p_value p_waers p_amt.
DATA : lv_amt(20) TYPE c.
DATA : lv_ext TYPE bapicurr-bapicurr.
CALL FUNCTION 'STRING_REPLACE'
EXPORTING
pattern = ','
substitute = ''
CHANGING
text = p_value.
IF sy-subrc NE 0.
ENDIF.
lv_ext = p_value.
CALL FUNCTION 'BAPI_CURRENCY_CONV_TO_INTERNAL'
EXPORTING
currency = p_waers
amount_external = lv_ext
max_number_of_digits = '11'
IMPORTING
amount_internal = lv_amt.
p_amt = lv_amt.
ENDFORM. "CONVERT_CHAR_TO_AMT
*&---------------------------------------------------------------------*
*& Form F4IF_INT_TABLE_VALUE_REQUEST
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->PT_VALUE_TAB text
* -->PT_FIELD_TAB text
* -->PT_RETURN_TAB text
* -->P_RETFIELD text
* -->P_DYNPROFIELD text
*----------------------------------------------------------------------*
FORM f4if_int_table_value_request TABLES pt_value_tab
pt_field_tab
pt_return_tab STRUCTURE ddshretval
USING p_retfield TYPE dfies-fieldname
p_dynprofield TYPE help_info-dynprofld.
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
retfield = p_retfield
dynpprog = sy-cprog
dynpnr = sy-dynnr
dynprofield = p_dynprofield
value_org = 'S'
* display = 'X'
TABLES
value_tab = pt_value_tab
field_tab = pt_field_tab
return_tab = pt_return_tab
EXCEPTIONS
parameter_error = 1
no_values_found = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDFORM. " f4if_int_table_value_request
*&---------------------------------------------------------------------*
*& Form POPUP_TO_CONFIRM_02
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->PV_TITLE text
* -->PV_QUESTION1 text
* -->PV_QUESTION2 text
* -->PV_ANSWER text
*----------------------------------------------------------------------*
FORM popup_to_confirm_02 USING pv_title
pv_question1
pv_question2
CHANGING pv_answer.
CALL FUNCTION 'POPUP_TO_CONFIRM_STEP'
EXPORTING
textline1 = pv_question1
textline2 = pv_question2
titel = pv_title
IMPORTING
answer = pv_answer. " J:예 N:아니오 A:취소
ENDFORM. " POPUP_TO_CONFIRM
*&---------------------------------------------------------------------*
*& Form POPUP_TO_CONFIRM
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_TITLE text
* -->P_TEXT text
* -->P_DEFAULT text
* -->P_CANC text
* -->P_ANSWER text
*----------------------------------------------------------------------*
FORM popup_to_confirm USING p_title
p_text
p_default
p_canc
CHANGING p_answer.
CALL FUNCTION 'POPUP_TO_CONFIRM'
EXPORTING
titlebar = p_title
text_question = p_text
text_button_1 = 'Yes'
text_button_2 = 'No'
default_button = p_default
display_cancel_button = p_canc
IMPORTING
answer = p_answer
EXCEPTIONS
text_not_found = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
CLEAR p_answer.
ENDIF.
ENDFORM. " POPUP_TO_CONFIRM
*&---------------------------------------------------------------------*
*& Form GET_LAST_DAY
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_DATE text
* -->P_LAST_DATE text
*----------------------------------------------------------------------*
FORM get_last_day USING p_date
CHANGING p_last_date.
"월의 마지막날 구하는 function.
CALL FUNCTION 'RP_LAST_DAY_OF_MONTHS'
EXPORTING
day_in = p_date
IMPORTING
last_day_of_month = p_last_date.
ENDFORM. " CHECK_VALIDATION
*&---------------------------------------------------------------------*
*& Form SET_DSMOD
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->PA_DSMOD text
*----------------------------------------------------------------------*
FORM set_dsmod USING pa_dsmod.
TRANSLATE pa_dsmod TO UPPER CASE.
IF pa_dsmod NA 'AEN'.
MESSAGE s000 DISPLAY LIKE 'E' WITH 'BDC Mode Fail'.
LEAVE LIST-PROCESSING.
ENDIF.
ENDFORM. " SET_DSMOD
*&---------------------------------------------------------------------*
*& Form FILE_EXISTS
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_FNAME text
* -->P_EXISTS text
*----------------------------------------------------------------------*
FORM file_exists USING p_fname p_exists.
DATA : l_result TYPE abap_bool.
DATA : l_filenm TYPE string.
CLEAR : p_exists.
p_exists = abap_false.
CHECK p_fname IS NOT INITIAL.
l_filenm = p_fname.
CALL METHOD cl_gui_frontend_services=>file_exist
EXPORTING
file = l_filenm
RECEIVING
result = l_result
EXCEPTIONS
cntl_error = 1
error_no_gui = 2
wrong_parameter = 3
not_supported_by_gui = 4
OTHERS = 5.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
p_exists = l_result.
ENDFORM. "FILE_EXISTS
*&---------------------------------------------------------------------*
*& Form AMT_CONV_TO_INTERNAL
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_WAERS text
* -->P_AMOUNT text
*----------------------------------------------------------------------*
FORM amt_conv_to_internal USING p_waers
CHANGING p_amount.
DATA: l_internal TYPE bapicurr-bapicurr.
l_internal = p_amount.
CALL FUNCTION 'BAPI_CURRENCY_CONV_TO_INTERNAL'
EXPORTING
currency = p_waers
amount_external = l_internal
max_number_of_digits = 22
IMPORTING
amount_internal = l_internal.
p_amount = l_internal.
ENDFORM. "amt_conv_to_external
*&---------------------------------------------------------------------*
*& Form GET_NEXT_NUMBER
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_NRRANG text
* -->P_OBJECT text
* -->P_DOCNO text
*----------------------------------------------------------------------*
FORM get_next_number USING p_nrrang p_object
CHANGING p_docno.
DATA : lv_fldnam TYPE string,
lv_nrrang LIKE inrdp-nrrangenr,
lv_object LIKE nriv-object.
lv_nrrang = p_nrrang.
lv_object = p_object.
CALL FUNCTION 'NUMBER_GET_NEXT'
EXPORTING
nr_range_nr = lv_nrrang
object = lv_object
IMPORTING
number = p_docno
EXCEPTIONS
interval_not_found = 1
number_range_not_intern = 2
object_not_found = 3
quantity_is_0 = 4
quantity_is_not_1 = 5
interval_overflow = 6
buffer_overflow = 7
OTHERS = 8.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
CLEAR p_docno.
ENDIF.
ENDFORM. " F_GET_NEXT_NUMBER
*&---------------------------------------------------------------------*
*& Form GET_NEXT_NUMBER_YEAR
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_NRRANG text
* -->P_OBJECT text
* -->P_YEAR text
* -->P_DOCNO text
*----------------------------------------------------------------------*
FORM get_next_number_year USING p_nrrang p_object p_year
CHANGING p_docno.
DATA : lv_fldnam TYPE string,
lv_nrrang LIKE inrdp-nrrangenr,
lv_object LIKE nriv-object,
lv_year LIKE inri-toyear.
lv_nrrang = p_nrrang.
lv_object = p_object.
IF p_year IS NOT INITIAL.
lv_year = p_year.
ELSE.
lv_year = '0000'.
ENDIF.
CALL FUNCTION 'NUMBER_GET_NEXT'
EXPORTING
nr_range_nr = lv_nrrang
object = lv_object
toyear = lv_year
IMPORTING
number = p_docno
EXCEPTIONS
interval_not_found = 1
number_range_not_intern = 2
object_not_found = 3
quantity_is_0 = 4
quantity_is_not_1 = 5
interval_overflow = 6
buffer_overflow = 7
OTHERS = 8.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
CLEAR p_docno.
ENDIF.
ENDFORM. " F_GET_NEXT_NUMBER_YEAR
*&---------------------------------------------------------------------*
*& Form GET_VALUE_LIST_DOM
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_TAB text
* -->P_DOMAIN text
*----------------------------------------------------------------------*
FORM get_value_list_dom TABLES p_tab
USING p_domain.
SELECT domvalue_l ddtext
INTO TABLE p_tab
FROM dd07t
WHERE domname EQ p_domain
AND ddlanguage EQ sy-langu
AND as4local EQ 'A'.
IF sy-subrc EQ 0.
SORT p_tab.
ELSE.
REFRESH p_tab.
ENDIF.
ENDFORM. " GET_VALUE_LIST_DOM
*&---------------------------------------------------------------------*
*& Form get_value_text
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_TAB text
* -->P_DOMAIN text
*----------------------------------------------------------------------*
FORM get_value_text USING p_domain
p_value
CHANGING p_text.
SELECT SINGLE ddtext
INTO p_text
FROM dd07t
WHERE domname EQ p_domain
AND ddlanguage EQ sy-langu
AND as4local EQ 'A'
AND domvalue_l EQ p_value.
ENDFORM. " get_value_text
*&---------------------------------------------------------------------*
*& Form GET_DOM_TEXT_LIST
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_DOMNA text
*----------------------------------------------------------------------*
FORM get_dom_text_list USING p_domna.
SELECT domname domvalue_l ddtext
APPENDING TABLE gt_domain
FROM dd07t
WHERE domname = p_domna
AND ddlanguage = sy-langu
AND as4local = 'A'.
SORT : gt_domain.
ENDFORM. " GET_DOM_TEXT_LIST
*&---------------------------------------------------------------------*
*& Form GET_FILE_PATH
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_FILENM text
*----------------------------------------------------------------------*
FORM get_file_path CHANGING p_filenm.
DATA: line_count TYPE i,
user_action TYPE i,
rtn_code LIKE sy-subrc,
lt_filetable TYPE filetable,
ls_filetable TYPE file_table.
CALL METHOD cl_gui_frontend_services=>file_open_dialog
EXPORTING
window_title = 'Upload'
multiselection = ' '
default_extension = 'XLS'
default_filename = ' '
file_filter = '*.XLS'
CHANGING
file_table = lt_filetable
rc = rtn_code
user_action = user_action.
CALL METHOD cl_gui_cfw=>flush.
CASE user_action.
WHEN cl_gui_frontend_services=>action_ok.
READ TABLE lt_filetable INTO ls_filetable INDEX 1.
CHECK sy-subrc IS INITIAL.
MOVE: ls_filetable-filename TO p_filenm.
WHEN cl_gui_frontend_services=>action_cancel.
ENDCASE.
ENDFORM. " GET_FILE_PATH
*&---------------------------------------------------------------------*
*& Form CHK_FILE_PATH
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_FNAME text
*----------------------------------------------------------------------*
FORM chk_file_path USING p_fname.
DATA: lv_result TYPE char1,
lv_file TYPE string.
MOVE: p_fname TO lv_file.
CALL METHOD cl_gui_frontend_services=>file_exist
EXPORTING
file = lv_file
RECEIVING
result = lv_result.
IF NOT sy-subrc IS INITIAL.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ELSEIF lv_result IS INITIAL.
MESSAGE s001(00) WITH 'Please check your file path'.
LEAVE LIST-PROCESSING.
ENDIF.
ENDFORM. " CHK_FILE_PATH
*&---------------------------------------------------------------------*
*& Form SET_BUTTON_100
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_NO text
* -->P_ICON text
* -->P_TEXT text
*----------------------------------------------------------------------*
FORM set_button_100 USING p_no TYPE numc2
p_icon p_text.
DATA : ls_functxt TYPE smp_dyntxt,
lv_fieldname(30).
FIELD-SYMBOLS <fs_func> LIKE sscrfields-functxt_01.
CONCATENATE 'SSCRFIELDS-FUNCTXT_' p_no INTO lv_fieldname.
ASSIGN (lv_fieldname) TO <fs_func>.
IF p_icon EQ space.
MOVE p_text TO <fs_func> .
ELSE.
ls_functxt-icon_id = p_icon.
ls_functxt-icon_text = p_text.
<fs_func> = ls_functxt.
ENDIF.
ENDFORM. " SET_BUTTON_100
*&---------------------------------------------------------------------*
*& Form GET_DYNP_VALUES_READ
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_FIELD text
*----------------------------------------------------------------------*
FORM get_dynp_values_read USING p_field.
DATA : lt_dynpfields TYPE TABLE OF dynpread,
ls_dynpfields TYPE dynpread,
lv_dyname TYPE sy-repid,
lv_dynum TYPE sy-dynnr.
FIELD-SYMBOLS <fs_field> TYPE any.
lv_dyname = sy-repid.
lv_dynum = sy-dynnr.
ls_dynpfields-fieldname = p_field.
APPEND ls_dynpfields TO lt_dynpfields.
CALL FUNCTION 'DYNP_VALUES_READ'
EXPORTING
dyname = lv_dyname
dynumb = lv_dynum
TABLES
dynpfields = lt_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.
EXIT.
ELSE.
READ TABLE lt_dynpfields INTO ls_dynpfields
WITH KEY fieldname = p_field.
IF sy-subrc EQ 0.
ASSIGN (p_field) TO <fs_field>.
IF <fs_field> IS ASSIGNED.
<fs_field> = ls_dynpfields-fieldvalue.
ENDIF.
ENDIF.
ENDIF.
ENDFORM. " GET_DYNP_VALUES_READ
*&---------------------------------------------------------------------*
*& Form SET_DYNP_VALUES
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_FIELD text
*----------------------------------------------------------------------*
FORM set_dynp_values USING p_field.
DATA : lt_dynpfields TYPE TABLE OF dynpread,
ls_dynpfields TYPE dynpread,
lv_dyname TYPE sy-repid,
lv_dynum TYPE sy-dynnr.
FIELD-SYMBOLS <fs_field> TYPE any.
lv_dyname = sy-repid.
lv_dynum = sy-dynnr.
ls_dynpfields-fieldname = p_field.
ASSIGN (p_field) TO <fs_field>.
IF <fs_field> IS ASSIGNED.
ls_dynpfields-fieldvalue = <fs_field>.
ENDIF.
APPEND ls_dynpfields TO lt_dynpfields.
CALL FUNCTION 'DYNP_VALUES_UPDATE'
EXPORTING
dyname = lv_dyname
dynumb = lv_dynum
TABLES
dynpfields = lt_dynpfields
EXCEPTIONS
invalid_abapworkarea = 1
invalid_dynprofield = 2
invalid_dynproname = 3
invalid_dynpronummer = 4
invalid_request = 5
no_fielddescription = 6
undefind_error = 7
OTHERS = 8.
IF sy-subrc <> 0.
EXIT.
ENDIF.
ENDFORM. " SET_DYNP_VALUES
*&---------------------------------------------------------------------*
*& Form SET_BTN_1000
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_0139 text
* -->P_ICON_XXL text
* -->P_0141 text
*----------------------------------------------------------------------*
FORM set_btn_1000 USING p_no TYPE numc2
p_icon p_text.
DATA : ls_functxt TYPE smp_dyntxt,
lv_fieldname(30).
FIELD-SYMBOLS <fs_func> LIKE sscrfields-functxt_01.
CONCATENATE 'SSCRFIELDS-FUNCTXT_' p_no INTO lv_fieldname.
ASSIGN (lv_fieldname) TO <fs_func>.
IF p_icon EQ space.
MOVE p_text TO <fs_func> .
ELSE.
ls_functxt-icon_id = p_icon.
ls_functxt-icon_text = p_text.
<fs_func> = ls_functxt.
ENDIF.
ENDFORM. " SET_BTN_1000
*&---------------------------------------------------------------------*
*& Form F_PDF_DOWNLOAD
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_JOB text
*----------------------------------------------------------------------*
FORM f_pdf_download USING p_job TYPE ssfcrescl.
DATA : lv_transfer_bin TYPE sx_boolean,
lt_content_txt TYPE soli_tab,
lt_content_bin TYPE solix_tab,
lt_objhead TYPE soli_tab,
lv_len_in LIKE sood-objlen,
ls_otf TYPE solisti1,
lv_bin_filesize TYPE i,
lv_bin_file TYPE xstring,
lt_lines LIKE tline OCCURS 0 WITH HEADER LINE.
DATA : lv_filesize TYPE i,
lv_filename TYPE string.
DATA : lt_otf TYPE TABLE OF itcoo WITH HEADER LINE.
lt_otf[] = p_job-otfdata.
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
format = 'PDF'
IMPORTING
bin_filesize = lv_bin_filesize
bin_file = lv_bin_file
TABLES
otf = lt_otf
lines = lt_lines
EXCEPTIONS
err_max_linewidth = 1
err_format = 2
err_conv_not_possible = 3
err_bad_otf = 4
OTHERS = 5.
LOOP AT lt_otf.
CONCATENATE lt_otf-tdprintcom lt_otf-tdprintpar INTO ls_otf.
APPEND ls_otf TO lt_content_txt.
ENDLOOP.
CALL FUNCTION 'SX_OBJECT_CONVERT_OTF_PDF'
EXPORTING
format_src = 'OTF'
format_dst = 'PDF'
devtype = 'PRINTER'
CHANGING
transfer_bin = lv_transfer_bin
content_txt = lt_content_txt
content_bin = lt_content_bin
objhead = lt_objhead
len = lv_len_in
EXCEPTIONS
err_conv_failed = 1
OTHERS = 2.
* pdf 다운로드
lv_filesize = lv_len_in.
PERFORM open_save_file_sel USING 'pdf' CHANGING lv_filename.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
bin_filesize = lv_filesize
filename = lv_filename
filetype = 'BIN'
TABLES
data_tab = lt_content_bin.
ENDFORM. " F_PDF_DOWNLOAD
*&---------------------------------------------------------------------*
*& Form OPEN_SAVE_FILE_SEL
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_EXT text
* -->P_FILENAME text
*----------------------------------------------------------------------*
FORM open_save_file_sel USING p_ext CHANGING p_filename.
DATA: lv_subrc LIKE sy-subrc,
lv_has_field_separator TYPE char01,
lv_filename TYPE string,
lv_path TYPE string,
lv_fullpath TYPE string,
lv_default_extension TYPE string,
lv_file_filter TYPE string,
lv_initial_directory TYPE string,
lv_default_file_name TYPE string,
lt_file_table TYPE filetable,
ls_file_table TYPE LINE OF filetable,
lv_user_action TYPE i.
CLEAR p_filename.
lv_default_extension = p_ext.
CONCATENATE '*.' p_ext INTO lv_default_file_name.
lv_initial_directory = 'C:\'.
CONCATENATE cl_gui_frontend_services=>filetype_all
* CL_GUI_FRONTEND_SERVICES=>FILETYPE_TEXT
cl_gui_frontend_services=>filetype_excel
INTO lv_file_filter.
CALL METHOD cl_gui_frontend_services=>file_save_dialog
EXPORTING
* WINDOW_TITLE
default_extension = lv_default_extension
default_file_name = lv_default_file_name
* WITH_ENCODING = ABAP_TRUE
file_filter = lv_file_filter
initial_directory = lv_initial_directory
CHANGING
filename = lv_filename
path = lv_path
fullpath = lv_fullpath
user_action = lv_user_action
EXCEPTIONS
cntl_error = 2
error_no_gui = 3
not_supported_by_gui = 4
OTHERS = 5.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
EXIT.
ELSE.
IF lv_user_action NE cl_gui_frontend_services=>action_ok.
EXIT.
ENDIF.
p_filename = lv_filename.
ENDIF.
ENDFORM. " OPEN_SAVE_FILE_SEL
*&---------------------------------------------------------------------*
*& Form ALSMEX_TAB_TO_ITAB
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->PT_INTERN text
* -->PT_EXCEL_TABLE text
* -->PS_EXCEL_STRUC text
*----------------------------------------------------------------------*
*FORM ALSMEX_TAB_TO_ITAB
* TABLES PT_INTERN STRUCTURE ALSMEX_TABLINE
* USING PT_EXCEL_TABLE PS_EXCEL_STRUC.
* FIELD-SYMBOLS : <FIELD> TYPE ANY.
* FIELD-SYMBOLS : <ITAB> TYPE STANDARD TABLE.
* FIELD-SYMBOLS : <ILINE> TYPE ANY.
*
* ASSIGN : (PT_EXCEL_TABLE) TO <ITAB>.
* ASSIGN : (PS_EXCEL_STRUC) TO <ILINE>.
*
* LOOP AT PT_INTERN.
* AT NEW ROW.
* CLEAR : <ILINE>.
* ENDAT.
*
* ASSIGN COMPONENT PT_INTERN-COL OF STRUCTURE <ILINE> TO <FIELD>.
*
* IF PT_INTERN-VALUE CO '0123456789,.- '.
* REPLACE ALL OCCURRENCES OF ',' IN PT_INTERN-VALUE WITH ''.
* ENDIF.
*
* MOVE PT_INTERN-VALUE TO <FIELD>.
*
* AT END OF ROW.
* APPEND <ILINE> TO <ITAB>.
* ENDAT.
* ENDLOOP.
*
*ENDFORM. " ALSMEX_TAB_TO_ITAB
**&---------------------------------------------------------------------*
**& Form START_INTERFACE_BDC
**&---------------------------------------------------------------------*
** text
**----------------------------------------------------------------------*
** -->P_MODE text
**----------------------------------------------------------------------*
*FORM START_INTERFACE_BDC USING P_MODE.
* CLEAR : FTPOST, FTPOST[].
* CLEAR : FTTAX, FTTAX[].
* CLEAR : BLNTAB, BLNTAB[].
* CLEAR : GV_FTPOST_TYPE.
* CLEAR : GV_FTPOST_CNT.
*
* CALL FUNCTION 'POSTING_INTERFACE_START'
* EXPORTING
* I_FUNCTION = 'C' " Using Call Transaction
* I_KEEP = 'Y'
* I_MODE = P_MODE
* I_UPDATE = 'S'
* EXCEPTIONS
* CLIENT_INCORRECT = 1
* FUNCTION_INVALID = 2
* GROUP_NAME_MISSING = 3
* MODE_INVALID = 4
* UPDATE_INVALID = 5
* OTHERS = 6.
*ENDFORM. " START_BDC
*
**&---------------------------------------------------------------------*
**& Form END_INTERFACE_BDC
**&---------------------------------------------------------------------*
** text
**----------------------------------------------------------------------*
*FORM END_INTERFACE_BDC.
* CALL FUNCTION 'POSTING_INTERFACE_END'
* EXPORTING
* I_BDCIMMED = 'X'.
*
* CLEAR : FTPOST, FTPOST[].
* CLEAR : FTTAX, FTTAX[].
* CLEAR : BLNTAB, BLNTAB[].
* CLEAR : GV_FTPOST_TYPE.
* CLEAR : GV_FTPOST_CNT.
*ENDFORM. "END_BDC
*&---------------------------------------------------------------------*
*& Form FILL_FIELD
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->FNAM text
* -->FVAL text
*----------------------------------------------------------------------*
FORM fill_field USING fnam fval fcurr_x.
"USING 'BSEG-WRBTR' GT_DATA-WRBTR_D 'X'.
DATA : lv_curr(15) TYPE c.
CHECK fval NE space.
ftpost-fnam = fnam.
ftpost-stype = gv_ftpost_type.
ftpost-count = gv_ftpost_cnt.
" 금액 필드일 경우.
IF fcurr_x = 'X'.
WRITE fval TO lv_curr CURRENCY
gv_ftpost_waers LEFT-JUSTIFIED.
CONDENSE lv_curr NO-GAPS.
WRITE lv_curr TO ftpost-fval.
ELSE.
WRITE fval TO ftpost-fval.
ENDIF.
APPEND ftpost.
CLEAR ftpost.
ENDFORM. "BUCHEN_FELD
*&---------------------------------------------------------------------*
*& Form BUILD_MESSGE_IF
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->PS_MESSAGE text
* -->PV_TEXT text
*----------------------------------------------------------------------*
FORM build_messge_if USING ps_message
STRUCTURE gt_if_msg CHANGING pv_text.
CLEAR pv_text.
CALL FUNCTION 'MESSAGE_TEXT_BUILD'
EXPORTING
msgid = ps_message-msgid
msgnr = ps_message-msgno
msgv1 = ps_message-msgv1
msgv2 = ps_message-msgv2
msgv3 = ps_message-msgv3
msgv4 = ps_message-msgv4
IMPORTING
message_text_output = pv_text.
ENDFORM. "BUILD_MESSGE_IF
*&---------------------------------------------------------------------*
*& Form GET_POST_PERIOD
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->PV_DATE text
* -->P_LFGJA text
* -->P_LFMON text
*----------------------------------------------------------------------*
FORM get_post_period USING pv_bukrs pv_date LIKE sy-datum
CHANGING p_lfgja p_lfmon.
CLEAR : p_lfgja, p_lfmon.
CALL FUNCTION 'FI_PERIOD_DETERMINE'
EXPORTING
i_bukrs = pv_bukrs
i_budat = pv_date
IMPORTING
e_gjahr = p_lfgja
e_monat = p_lfmon
EXCEPTIONS
fiscal_year = 1
period = 2
period_version = 3
posting_period = 4
special_period = 5
version = 6
posting_date = 7
OTHERS = 8.
IF sy-subrc NE 0.
p_lfgja = pv_date(4).
p_lfmon = pv_date+4(2).
ENDIF.
ENDFORM. "GET_POST_PERIOD
*&---------------------------------------------------------------------*
*& Form GET_KOKRS_TXT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_KOKRS text
* -->P_BEZEI text
*----------------------------------------------------------------------*
FORM set_kokrs_base USING p_kokrs.
SELECT SINGLE bezei ktopl
INTO (gv_kbezei_cm, gv_ktopl_cm)
FROM tka01
WHERE kokrs = p_kokrs.
ENDFORM. "GET_KOKRS_TXT
*&---------------------------------------------------------------------*
*& Form CONV_DB_WAERS
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_VALUE text
*----------------------------------------------------------------------*
FORM conv_db_waers USING p_value p_waers.
CALL FUNCTION 'CURRENCY_AMOUNT_IDOC_TO_SAP'
EXPORTING
currency = p_waers
idoc_amount = p_value
IMPORTING
sap_amount = p_value.
ENDFORM. "TO_KRW
*&---------------------------------------------------------------------*
*& Form CONV_VIEW_WAERS
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_VALUE text
* -->P_WAERS text
* -->P_DOC_VALUE text
*----------------------------------------------------------------------*
FORM conv_view_waers USING p_value p_waers
CHANGING p_doc_value.
CALL FUNCTION 'CURRENCY_AMOUNT_SAP_TO_IDOC'
EXPORTING
currency = p_waers
sap_amount = p_value
IMPORTING
idoc_amount = p_doc_value.
ENDFORM. "TO_KRW
*&---------------------------------------------------------------------*
*& Form CONVERT_1000
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_VALUE text
* -->P_VALUE_1000 text
*----------------------------------------------------------------------*
*FORM CONVERT_1000_U USING P_VALUE
* CHANGING P_VALUE_1000.
* P_VALUE_1000 = P_VALUE * 1000.
*ENDFORM. "CONVERT_1000
*&---------------------------------------------------------------------*
*& Form CONVERT_1000_D
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_VALUE text
* -->P_VALUE_1000 text
*----------------------------------------------------------------------*
*FORM CONVERT_1000_D USING P_VALUE
* CHANGING P_VALUE_1000.
* P_VALUE_1000 = P_VALUE / 1000.
*ENDFORM. "CONVERT_1000
*&---------------------------------------------------------------------*
*& Form GET_VERSN_TEXT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_KOKRS text
* -->P_VERSN text
* -->P_VERSN_TXT text
*----------------------------------------------------------------------*
*FORM GET_VERSN_TEXT USING P_KOKRS P_VERSN
* CHANGING P_VERSN_TXT.
* CLEAR : P_VERSN_TXT.
* SELECT SINGLE TXT
* INTO P_VERSN_TXT
* FROM TKT09
* WHERE KOKRS = P_KOKRS
* AND VERSN = P_VERSN
* AND LANGU = SY-LANGU.
*ENDFORM. "GET_VERSN_TEXT
*&---------------------------------------------------------------------*
*& Form UPLOAD_XLS_STRUCT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_TABLE text
* -->P_FILE text
* -->P_SCOL text
* -->P_SROW text
* -->P_ECOL text
* -->P_EROW text
*----------------------------------------------------------------------*
FORM upload_xls_struct TABLES p_table
USING p_file
p_scol
p_srow
p_ecol
p_erow.
DATA : lt_intern TYPE alsmex_tabline OCCURS 0 WITH HEADER LINE.
DATA : lv_index TYPE i.
FIELD-SYMBOLS : <fs_line>.
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
filename = p_file
i_begin_col = p_scol
i_begin_row = p_srow
i_end_col = p_ecol
i_end_row = p_erow
TABLES
intern = lt_intern
EXCEPTIONS
inconsistent_parameters = 1
upload_ole = 2
OTHERS = 3.
IF sy-subrc <> 0.
FORMAT COLOR COL_BACKGROUND INTENSIFIED.
WRITE:/ 'Error Uploading file'.
EXIT.
ENDIF.
IF lt_intern[] IS INITIAL.
FORMAT COLOR COL_BACKGROUND INTENSIFIED.
WRITE:/ 'No Data Uploaded'.
EXIT.
ELSE.
SORT lt_intern BY row col.
LOOP AT lt_intern.
MOVE lt_intern-col TO lv_index.
ASSIGN COMPONENT lv_index OF STRUCTURE p_table TO <fs_line>.
IF lt_intern-value CO '0123456789,.- '.
REPLACE ALL OCCURRENCES OF ',' IN lt_intern-value WITH ''.
ENDIF.
MOVE lt_intern-value TO <fs_line>.
AT END OF row.
APPEND p_table.
CLEAR p_table.
ENDAT.
ENDLOOP.
ENDIF.
ENDFORM. "UPLOAD_EXCEL_FILE
*&---------------------------------------------------------------------*
*& Form SET_PREV_MONTH
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_P_GJAHR text
* -->P_P_PERDE text
*----------------------------------------------------------------------*
FORM set_prev_month USING pv_gjahr
pv_perde.
DATA : lv_date LIKE sy-datum.
CALL FUNCTION 'RP_CALC_DATE_IN_INTERVAL'
EXPORTING
date = sy-datum
days = '00'
months = '01'
signum = '-'
years = '00'
IMPORTING
calc_date = lv_date.
pv_gjahr = lv_date+0(4).
pv_perde = lv_date+4(2).
ENDFORM. " SET_PREV_MONTH
*&---------------------------------------------------------------------*
*& Form GET_CSKT_KTEXT
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
* -->P_GS_ZTFICD10_ACC_CD text
* <--P_GS_ZTFICD10_KTEXT text
*&---------------------------------------------------------------------*
FORM get_cskt_ktext USING pv_kostl
CHANGING pv_ktext.
SELECT SINGLE ktext
INTO pv_ktext
FROM cskt
WHERE spras EQ '3'
AND kokrs EQ '1000'
AND kostl EQ pv_kostl
AND datbi EQ '99991231'.
ENDFORM.
*& Include ZFI_COMMON
*&---------------------------------------------------------------------*
********************************************************
* 공통변수
********************************************************
TABLES: bdcmsgcoll, "* Collecting messages in the SAP System
alsmex_tabline, "* Rows for Table with Excel Data
tbtco, "* Job status overview table
rfcdoc,
rfcdes,
dbcon,
stxh.
TYPE-POOLS: kcde, vrm, icon, scp1, gseth, slis.
" Progress bar Message
DATA : gv_calc_i TYPE i. "* %
DATA : gv_progress_msg(100). "* Display
DATA : gv_calc_c0(5).
DATA : gv_calc_c1(5).
" group select
DATA : gv_value_set TYPE gseth_val_line.
DATA : gt_value_set TYPE gseth_val_tab.
DATA : gt_detmsg TYPE TABLE OF scp1_general_error.
DATA : gt_heamsg TYPE TABLE OF scp1_general_error.
"도메인 가져오기
DATA : BEGIN OF gs_domain,
domain LIKE dd07t-domname,
value LIKE dd07t-domvalue_l,
ddtext LIKE dd07t-ddtext,
END OF gs_domain.
DATA : gt_domain LIKE TABLE OF gs_domain.
" 엑셀 내보내기용
TYPES : BEGIN OF t_excel_export,
excel_col TYPE string,
END OF t_excel_export.
DATA : gt_excel_export TYPE t_excel_export OCCURS 0 WITH HEADER LINE.
" 조회 권한
*-- 'X'일때에는 조회만 가능
DATA : gv_dip_mod TYPE c.
*-------------------------------------------------
* Company Code 정보.
*-------------------------------------------------
DATA : gv_butxt_cm TYPE t001-butxt VALUE ''.
DATA : gv_kokrs_txt TYPE tkt09-txt VALUE ''.
DATA : gv_waers_cm TYPE t001-waers VALUE ''.
DATA : gv_ktopl_cm TYPE t001-ktopl VALUE ''.
DATA : gv_spras_cm TYPE t001-spras VALUE ''. " KO
DATA : gv_land1_cm TYPE t001-land1 VALUE ''.
DATA : gv_kbezei_cm LIKE tka01-bezei VALUE ''. "
*-----------------------------------------------
* BDC DEFINITION
* ----------------------------------------------
DATA: gs_bdc_option TYPE ctu_params.
DATA: gt_bdcdata LIKE bdcdata OCCURS 0 WITH HEADER LINE.
DATA: gt_messtab LIKE bdcmsgcoll OCCURS 0 WITH HEADER LINE.
****************************************
* POSTING_INTERFACE_DOCUMENT.
****************************************
DATA : ftpost LIKE ftpost OCCURS 0 WITH HEADER LINE.
DATA : fttax LIKE fttax OCCURS 0 WITH HEADER LINE.
DATA : blntab LIKE blntab OCCURS 0 WITH HEADER LINE.
DATA : gv_ftpost_type TYPE c.
DATA : gv_ftpost_cnt TYPE i.
DATA : gv_ftpost_waers LIKE t001-waers.
DATA : BEGIN OF gt_if_msg OCCURS 0,
msgid LIKE sy-msgid,
msgno LIKE sy-msgno,
msgty LIKE sy-msgty,
msgv1 LIKE sy-msgv1,
msgv2 LIKE sy-msgv2,
msgv3 LIKE sy-msgv3,
msgv4 LIKE sy-msgv4,
subrc LIKE sy-subrc,
message LIKE bdcmsgcoll-msgv1,
END OF gt_if_msg.
****************************************
" 값이 없으면 BDC를 태우지 않음.
DATA : BEGIN OF gt_excp_init_field OCCURS 0,
fname TYPE fnam_____4,
END OF gt_excp_init_field.
********************************************************
* 매크로
********************************************************
*-----------------------------------------------
* MACRO DEFINITION
* ----------------------------------------------
"SETNODE 내역을 RANGE 변수에 INSERT.
DEFINE macro_value_to_range.
CLEAR : gv_value_set.
CLEAR : &1. REFRESH : &1.
LOOP AT &2 INTO gv_value_set.
&1-low = gv_value_set-vfrom.
&1-sign = 'I'.
IF gv_value_set-vfrom NE gv_value_set-vto.
&1-option = 'BT'.
&1-high = gv_value_set-vto.
ELSE.
&1-option = 'EQ'.
ENDIF.
APPEND &1.
CLEAR : &1.
ENDLOOP.
CLEAR : &2. REFRESH : &2.
END-OF-DEFINITION.
DEFINE add_range_eq.
IF &2 NE space.
CLEAR &1.
&1-sign = 'I'.
&1-option = 'EQ'.
&1-low = &2.
APPEND &1.
ENDIF.
END-OF-DEFINITION.
DEFINE add_range_full.
CLEAR &1.
&1-sign = &2.
&1-option = &3.
&1-low = &4.
&1-high = &5.
APPEND &1.
END-OF-DEFINITION.
*&---------------------------------------------------------------------*
*& Form ADD_EXCP_FIELD_WHEN_INITIAL
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_FIELD text
*----------------------------------------------------------------------*
FORM add_excp_field_when_initial USING p_field.
DATA : l_excp_field LIKE LINE OF gt_excp_init_field.
CLEAR : l_excp_field.
l_excp_field-fname = p_field.
APPEND l_excp_field TO gt_excp_init_field.
ENDFORM. "ADD_EXCP_FIELD_WHEN_INITIAL
*&---------------------------------------------------------------------*
*& Form GET_INFO_LIKE_ITAB
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->PT_REF_FCAT text
* -->P_ITAB_NAME text
*----------------------------------------------------------------------*
FORM get_fcat_like_itab
TABLES pt_ref_fcat STRUCTURE lvc_s_fcat
USING p_itab_name TYPE dd03l-tabname.
DATA : lt_table LIKE dd02l-tabname OCCURS 0 WITH HEADER LINE.
DATA : lt_fieldcat TYPE slis_t_fieldcat_alv.
DATA : lt_alv_cat TYPE TABLE OF lvc_s_fcat.
CLEAR : lt_table, lt_table[].
CLEAR : lt_fieldcat, lt_fieldcat[].
CLEAR : lt_alv_cat, lt_alv_cat[].
"Internal Table 데이터 구성-> Fieldcat mege로 부터
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = sy-repid
i_internal_tabname = p_itab_name
i_inclname = sy-repid
i_structure_name = ''
i_bypassing_buffer = 'X'
CHANGING
ct_fieldcat = lt_fieldcat[]
EXCEPTIONS
inconsistent_interface = 1
program_error = 2.
CALL FUNCTION 'LVC_TRANSFER_FROM_SLIS'
EXPORTING
it_fieldcat_alv = lt_fieldcat
IMPORTING
et_fieldcat_lvc = lt_alv_cat
TABLES
it_data = lt_table[].
CALL FUNCTION 'LVC_FIELDCAT_COMPLETE'
CHANGING
ct_fieldcat = lt_alv_cat.
pt_ref_fcat[] = lt_alv_cat[].
CLEAR : lt_alv_cat, lt_alv_cat[].
ENDFORM. " GET_DD03_FCAT
*&---------------------------------------------------------------------*
*& Form SET_COMPANY_BASE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM set_company_base USING p_bukrs.
DATA : l_t001 LIKE t001.
CLEAR : l_t001.
SELECT SINGLE *
FROM t001
INTO l_t001
WHERE bukrs = p_bukrs.
IF sy-subrc EQ 0.
gv_waers_cm = l_t001-waers.
gv_ktopl_cm = l_t001-ktopl.
gv_spras_cm = l_t001-spras.
gv_butxt_cm = l_t001-butxt.
gv_land1_cm = l_t001-land1.
ENDIF.
ENDFORM. " SET_COMPANY_BASE
*PERFORM GET_SETLEAF_VALUES USING
* 'BUDGET' '0102'. =>1. GT_VALUE_SET에 값이 담김.
* MACRO_VALUE_TO_RANGE : => 2. 넘겨준 RANGE 변수에 값이 담김
* GR_BUDGET_KSTAR => 로컬 변수
* GT_VALUE_SET. => 매크로 이후 메모리에서 제거됨.
FORM get_setleaf_values
USING p_kokrs p_setname TYPE any
pv_class TYPE sethier-setclass.
DATA : lt_node TYPE gseth_node_tab.
DATA : l_class TYPE sethier-setclass.
DATA : l_setid TYPE sethier-setid.
DATA : lt_grphinfo TYPE grphinfo OCCURS 0 WITH HEADER LINE.
DATA : l_message TYPE string.
CLEAR : lt_node, lt_node[].
CLEAR : l_class, l_setid.
CLEAR : lt_grphinfo, lt_grphinfo[].
CLEAR : gt_value_set, gt_value_set[].
CLEAR : l_message.
l_class = pv_class.
CASE pv_class.
WHEN '0101'. " 코스트센터
CONCATENATE pv_class p_kokrs p_setname INTO l_setid.
WHEN '0102'. " 원가요소
CONCATENATE pv_class gv_ktopl_cm p_setname INTO l_setid.
WHEN '0103'. " 오더
* CONCATENATE PV_CLASS GC_KOKRS P_SETNAME INTO L_SETID.
CONCATENATE pv_class p_setname INTO l_setid. " New GL/Segment
WHEN '0106'. " 손익센터
CONCATENATE pv_class p_kokrs p_setname INTO l_setid.
WHEN '0109'. " 계정과목
CONCATENATE pv_class gv_ktopl_cm p_setname INTO l_setid.
ENDCASE.
CALL FUNCTION 'K_HIERARCHY_TABLES_READ'
EXPORTING
e_class = l_class
e_setid = l_setid
e_kokrs = p_kokrs
e_mandt = sy-mandt
TABLES
t_nodes = lt_node
t_values = gt_value_set
CHANGING
c_info = lt_grphinfo
c_overwrite = sy-datar
EXCEPTIONS
no_controlling_area = 1
no_chart_of_account = 2
different_controlling_areas = 3
different_chart_of_accounts = 4
set_not_found = 5
illegal_field_replacement = 6
illegal_table_replacement = 7
fm_raise = 8
convert_error = 9
no_overwrite_standard_hier = 10
no_bukrs_for_kokrs = 11
OTHERS = 12.
IF sy-subrc <> 0.
* MESSAGE ID 'GS' TYPE 'E' NUMBER '004'
* WITH P_SETNAME INTO L_MESSAGE.
* MESSAGE S000(ZCOM1) DISPLAY LIKE 'E' WITH L_MESSAGE.
* LEAVE LIST-PROCESSING.
ENDIF.
ENDFORM. "GET_SET_VALUES
*&---------------------------------------------------------------------*
*& Form DYNPRO
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->PT_BDCTAB text
* -->PV_DYNBEGIN text
* -->PV_INPUT text
* -->PV_VALUE text
*----------------------------------------------------------------------*
FORM dynpro TABLES pt_bdctab
USING pv_dynbegin pv_input pv_value.
DATA : ls_bdctab TYPE bdcdata.
CLEAR : ls_bdctab.
IF pv_dynbegin = 'X'.
WRITE : pv_input TO ls_bdctab-program LEFT-JUSTIFIED.
WRITE : pv_value TO ls_bdctab-dynpro LEFT-JUSTIFIED.
WRITE : 'X' TO ls_bdctab-dynbegin LEFT-JUSTIFIED.
APPEND ls_bdctab TO pt_bdctab.
ELSE.
READ TABLE gt_excp_init_field TRANSPORTING NO FIELDS
WITH KEY fname = pv_input BINARY SEARCH.
IF sy-subrc EQ 0 AND pv_value IS INITIAL.
EXIT.
ENDIF.
WRITE : pv_input TO ls_bdctab-fnam LEFT-JUSTIFIED.
WRITE : pv_value TO ls_bdctab-fval LEFT-JUSTIFIED.
APPEND ls_bdctab TO pt_bdctab.
ENDIF.
ENDFORM. "SET_DYNPRO
*ZCOC9060 업데이트용 BDC
FORM dynpro_update TABLES pt_bdctab
USING pv_dynbegin pv_input pv_value.
DATA : ls_bdctab TYPE bdcdata.
DATA : string_type(4) TYPE c.
CLEAR : ls_bdctab.
IF pv_dynbegin = 'X'.
WRITE : pv_input TO ls_bdctab-program LEFT-JUSTIFIED.
WRITE : pv_value TO ls_bdctab-dynpro LEFT-JUSTIFIED.
WRITE : 'X' TO ls_bdctab-dynbegin LEFT-JUSTIFIED.
APPEND ls_bdctab TO pt_bdctab.
ELSE.
* READ TABLE GT_EXCP_INIT_FIELD TRANSPORTING NO FIELDS
* WITH KEY FNAME = PV_INPUT BINARY SEARCH.
IF pv_value IS INITIAL.
EXIT.
ENDIF.
CALL FUNCTION 'NUMERIC_CHECK'
EXPORTING
string_in = pv_value
IMPORTING
htype = string_type.
IF string_type = 'CHAR'.
IF pv_value = '@'.
WRITE : pv_input TO ls_bdctab-fnam LEFT-JUSTIFIED.
WRITE : '' TO ls_bdctab-fval LEFT-JUSTIFIED.
APPEND ls_bdctab TO pt_bdctab.
EXIT.
ENDIF.
ENDIF.
WRITE : pv_input TO ls_bdctab-fnam LEFT-JUSTIFIED.
WRITE : pv_value TO ls_bdctab-fval LEFT-JUSTIFIED.
APPEND ls_bdctab TO pt_bdctab.
ENDIF.
ENDFORM. "SET_DYNPRO
*&---------------------------------------------------------------------*
*& Form SET_BDC_OPTION
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->PV_DEFSIZE text
* -->PV_UPDMODE text
* -->PV_CATTMODE text
* -->PV_DISMODE text
* -->PV_RACCOMMIT text
* -->PV_NOBINPT text
* -->PS_CTU_PARAMS text
*----------------------------------------------------------------------*
FORM set_bdc_option
USING pv_defsize
pv_updmode
pv_cattmode
pv_dismode
pv_raccommit
pv_nobinpt
CHANGING ps_ctu_params STRUCTURE ctu_params.
ps_ctu_params-defsize = pv_defsize.
ps_ctu_params-updmode = pv_updmode.
ps_ctu_params-cattmode = pv_cattmode.
ps_ctu_params-dismode = pv_dismode.
ps_ctu_params-racommit = pv_raccommit.
ps_ctu_params-nobinpt = pv_nobinpt.
ps_ctu_params-defsize = pv_defsize.
ENDFORM. "SET_BDC_OPTION
*&---------------------------------------------------------------------*
*& Form ZERO_O
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_IN text
* -->P_OUT text
*----------------------------------------------------------------------*
FORM zero_o USING p_in p_out.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
EXPORTING
input = p_in
IMPORTING
output = p_out.
ENDFORM. "ZERO_O
*&---------------------------------------------------------------------*
*& Form ZERO_I
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_IN text
* -->P_OUT text
*----------------------------------------------------------------------*
FORM zero_i USING p_in p_out.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = p_in
IMPORTING
output = p_out.
ENDFORM. "ZERO_I
*&---------------------------------------------------------------------*
*& Form BAR_MSG
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_PER text
* -->VALUE(P_MSG) text
*----------------------------------------------------------------------*
FORM bar_msg USING p_per TYPE i VALUE(p_msg).
CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
EXPORTING
percentage = p_per
text = p_msg.
ENDFORM. "BAR_MSG
*&---------------------------------------------------------------------*
*& Form BAR_MSG_PER
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_TEXT text
* -->P_CNT1 text
* -->P_CNT2 text
*----------------------------------------------------------------------*
" P_CNT1 : 현재 COUNT
" P_CNT2 : 총 COUNT
*&---------------------------------------------------------------------*
*& Form BAR_MSG_PER
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_TEXT text
* -->P_CNT1 text
* -->P_CNT2 text
*----------------------------------------------------------------------*
FORM bar_msg_per USING p_text p_cnt1 p_cnt2.
DATA : l_ncnt1(5) TYPE n.
DATA : l_ncnt2(5) TYPE n.
CLEAR : l_ncnt1, l_ncnt2.
l_ncnt1 = p_cnt1.
l_ncnt2 = p_cnt2.
gv_calc_i = p_cnt1 * 100 / p_cnt2.
gv_calc_c0 = gv_calc_i.
IF l_ncnt1 IS INITIAL AND l_ncnt2 IS INITIAL.
gv_progress_msg = p_text.
ELSE.
CONCATENATE p_text '(' gv_calc_c0 '% )'
INTO gv_progress_msg SEPARATED BY space.
CONDENSE gv_progress_msg.
ENDIF.
CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
EXPORTING
percentage = gv_calc_i
text = gv_progress_msg.
ENDFORM. " process_bar
*&---------------------------------------------------------------------*
*& Form DISPLAY_SPOOL_BY_SALV
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->PT_TABLE text
*----------------------------------------------------------------------*
*FORM DISPLAY_SPOOL_BY_SALV TABLES PT_TABLE.
* DATA : GR_TABLE TYPE REF TO CL_SALV_TABLE.
** SORT GT_DISPLAY.
* CL_SALV_TABLE=>FACTORY(
* IMPORTING
* R_SALV_TABLE = GR_TABLE
* CHANGING
* T_TABLE = PT_TABLE[] ).
*
* GR_TABLE->DISPLAY( ).
*ENDFORM. "DISPLAY_SPOOL_BY_SALV
*&---------------------------------------------------------------------*
*& Form SET_FRONT_MINUS
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_NUM text
*----------------------------------------------------------------------*
FORM set_minus_front CHANGING p_num.
CALL FUNCTION 'CLOI_PUT_SIGN_IN_FRONT'
CHANGING
value = p_num.
ENDFORM. " SET_FRONT_MINUS
*&---------------------------------------------------------------------*
*& Form F4_FNAME
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_NAME text
*----------------------------------------------------------------------*
FORM f4_fname CHANGING p_name.
DATA: file_table TYPE filetable,
rc TYPE i,
filedat TYPE string.
CALL METHOD cl_gui_frontend_services=>file_open_dialog
EXPORTING
default_filename = space
initial_directory = 'C:\'
CHANGING
file_table = file_table
rc = rc
EXCEPTIONS
OTHERS = 1.
IF sy-subrc <> 0.
EXIT.
ENDIF.
READ TABLE file_table INDEX 1 INTO filedat.
CHECK NOT filedat IS INITIAL.
p_name = filedat.
ENDFORM. " FILE_UPLOAD
*&---------------------------------------------------------------------*
*& Form UPLOAD_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->PT_EXCEL_TABLE text
* -->PS_EXCEL_STRUC text
* -->PV_EXCEL_FILENAME text
* -->PV_BEGIN_COL text
* -->PV_BEGIN_ROW text
* -->PV_END_COL text
* -->PV_END_ROW text
*----------------------------------------------------------------------*
FORM upload_data USING pt_excel_table
ps_excel_struc
pv_excel_filename
pv_begin_col TYPE i
pv_begin_row TYPE i
pv_end_col TYPE i
pv_end_row TYPE i.
DATA : lt_intern LIKE alsmex_tabline OCCURS 0 WITH HEADER LINE.
FIELD-SYMBOLS : <l_fs01>,
<l_fs02> TYPE STANDARD TABLE,
<l_fs03>.
ASSIGN: (pt_excel_table) TO <l_fs02>,
(ps_excel_struc) TO <l_fs03>.
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
filename = pv_excel_filename
i_begin_col = pv_begin_col
i_begin_row = pv_begin_row
i_end_col = pv_end_col
i_end_row = pv_end_row
TABLES
intern = lt_intern
EXCEPTIONS
inconsistent_parameters = 1
upload_ole = 2
OTHERS = 3.
IF sy-subrc <> 0.
IF sy-msgid IS INITIAL.
MESSAGE i000 WITH 'No Selected File Exists or Too Long File path'.
LEAVE LIST-PROCESSING.
ELSE.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDIF.
LOOP AT lt_intern.
AT NEW row.
CLEAR : <l_fs03>.
ENDAT.
ASSIGN COMPONENT lt_intern-col OF STRUCTURE <l_fs03> TO <l_fs01>.
IF lt_intern-value CO '0123456789,.- '.
REPLACE ALL OCCURRENCES OF ',' IN lt_intern-value WITH ''.
ENDIF.
MOVE lt_intern-value TO <l_fs01>.
AT END OF row.
APPEND <l_fs03> TO <l_fs02>.
ENDAT.
ENDLOOP.
ENDFORM. " UPLOAD_DATA
*&---------------------------------------------------------------------*
*& Form BDC_DATE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_DATE text
*----------------------------------------------------------------------*
FORM bdc_date CHANGING p_date.
REPLACE ALL OCCURRENCES OF '.' IN p_date WITH ''.
REPLACE ALL OCCURRENCES OF '-' IN p_date WITH ''.
REPLACE ALL OCCURRENCES OF '/' IN p_date WITH ''.
ENDFORM. " CONVERT_TO_SAP_DATE
*&---------------------------------------------------------------------*
*& Form BDC_CURR
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_DMBTR text
*----------------------------------------------------------------------*
FORM bdc_curr CHANGING p_dmbtr.
REPLACE ALL OCCURRENCES OF ',' IN p_dmbtr WITH ''.
ENDFORM. " CONVERT_TO_DMBTR
*&---------------------------------------------------------------------*
*& Form BDC_CHECKBOX
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_VALUE text
*----------------------------------------------------------------------*
FORM bdc_checkbox USING p_value.
TRANSLATE p_value TO UPPER CASE.
ENDFORM. " BDC_CHECKBOX
*&---------------------------------------------------------------------*
*& Form BUILD_MESSAGE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->PS_MESSAGE text
* -->PV_TEXT text
*----------------------------------------------------------------------*
FORM build_message USING ps_message STRUCTURE bdcmsgcoll
CHANGING pv_text.
CLEAR pv_text.
CALL FUNCTION 'MESSAGE_TEXT_BUILD'
EXPORTING
msgid = ps_message-msgid
msgnr = ps_message-msgnr
msgv1 = ps_message-msgv1
msgv2 = ps_message-msgv2
msgv3 = ps_message-msgv3
msgv4 = ps_message-msgv4
IMPORTING
message_text_output = pv_text.
REPLACE ALL OCCURRENCES OF '&' IN pv_text WITH ''.
* CONCATENATE PS_MESSAGE-FLDNAME PV_TEXT
* INTO PV_TEXT SEPARATED BY SPACE.
ENDFORM. " MESSAGE_BUILD
*&---------------------------------------------------------------------*
*& Form BUILD_MESSAGE_BAPI
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->PS_MESSAGE text
* -->PV_TEXT text
*----------------------------------------------------------------------*
FORM build_message_bapi USING ps_message STRUCTURE bapiret2
CHANGING pv_text.
CLEAR pv_text.
CALL FUNCTION 'MESSAGE_TEXT_BUILD'
EXPORTING
msgid = ps_message-id
msgnr = ps_message-number
msgv1 = ps_message-message_v1
msgv2 = ps_message-message_v2
msgv3 = ps_message-message_v3
msgv4 = ps_message-message_v4
IMPORTING
message_text_output = pv_text.
REPLACE ALL OCCURRENCES OF '&' IN pv_text WITH ''.
* CONCATENATE PS_MESSAGE-FLDNAME PV_TEXT
* INTO PV_TEXT SEPARATED BY SPACE.
ENDFORM. " MESSAGE_BUILD
*&---------------------------------------------------------------------*
*& Form EXCEL_FORM_DOWNLOAD
*&---------------------------------------------------------------------*
* text0
*----------------------------------------------------------------------*
FORM excel_form_download TABLES pt_excel_export
STRUCTURE gt_excel_export.
DATA : lt_fcat TYPE TABLE OF lvc_s_fcat.
DATA : ls_fcat TYPE lvc_s_fcat.
DATA : l_cnt(2) TYPE n VALUE '01'.
DATA : l_colname(20) TYPE c.
DATA : l_size TYPE i.
DATA : lf_data TYPE REF TO data.
DATA : ll_data TYPE REF TO data.
DATA : l_usr_act TYPE i.
DATA : l_file_len TYPE i.
DATA : l_fname TYPE string.
DATA : l_ext_filename TYPE string.
DATA : l_fullpath TYPE string.
DATA : l_path TYPE string.
FIELD-SYMBOLS : <fs_table> TYPE STANDARD TABLE.
FIELD-SYMBOLS : <fs_line> TYPE any.
FIELD-SYMBOLS : <fs_col> TYPE any.
DEFINE add_excel_col.
CLEAR : l_colname.
l_size = strlen( &1 ) + 2.
CONCATENATE 'COL' l_cnt INTO l_colname.
ls_fcat-fieldname = l_colname.
ls_fcat-col_pos = l_cnt.
ls_fcat-coltext = &1.
ls_fcat-inttype = 'C'.
ls_fcat-intlen = l_size.
APPEND ls_fcat TO lt_fcat.
l_cnt = l_cnt + 1.
CLEAR : ls_fcat, l_colname.
CLEAR : l_size.
END-OF-DEFINITION.
CLEAR : l_fname, l_ext_filename, l_fullpath, l_path.
CLEAR : l_usr_act, l_file_len.
CLEAR : lt_fcat, lt_fcat[].
CLEAR : ls_fcat.
CHECK pt_excel_export[] IS NOT INITIAL.
LOOP AT pt_excel_export.
add_excel_col : pt_excel_export-excel_col.
ENDLOOP.
" 동적 테이블 생성
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = lt_fcat
IMPORTING
ep_table = lf_data.
ASSIGN lf_data->* TO <fs_table>.
" 테이블 라인 생성
CREATE DATA ll_data LIKE LINE OF <fs_table>.
ASSIGN ll_data->* TO <fs_line>.
" 템플릿 내용 단 한라인만 등록
LOOP AT lt_fcat INTO ls_fcat.
ASSIGN COMPONENT ls_fcat-col_pos
OF STRUCTURE <fs_line> TO <fs_col>.
IF sy-subrc EQ 0.
<fs_col> = ls_fcat-coltext. " COLTEXT 의 내용을 그대로.
ENDIF.
ENDLOOP.
" 테이블에 담기.
APPEND <fs_line> TO <fs_table>.
CHECK <fs_table> IS NOT INITIAL.
CONCATENATE sy-repid '_UploadForm.xls' INTO l_fname.
CALL METHOD cl_gui_frontend_services=>file_save_dialog
EXPORTING
default_extension = 'XLS'
default_file_name = l_fname
file_filter = '*.XLS'
CHANGING
filename = l_ext_filename
path = l_path
fullpath = l_fullpath
user_action = l_usr_act.
IF l_usr_act = '0'.
CALL METHOD cl_gui_frontend_services=>gui_download
EXPORTING
filename = l_fullpath
write_field_separator = 'X'
IMPORTING
filelength = l_file_len
CHANGING
data_tab = <fs_table>
EXCEPTIONS
file_write_error = 1
no_batch = 2
gui_refuse_filetransfer = 3
invalid_type = 4
no_authority = 5
unknown_error = 6
header_not_allowed = 7
separator_not_allowed = 8
filesize_not_allowed = 9
header_too_long = 10
dp_error_create = 11
dp_error_send = 12
dp_error_write = 13
unknown_dp_error = 14
access_denied = 15
dp_out_of_memory = 16
disk_full = 17
dp_timeout = 18
file_not_found = 19
dataprovider_exception = 20
control_flush_error = 21
OTHERS = 22.
IF sy-subrc = 0.
MESSAGE s000 WITH 'Success.'.
ELSE.
MESSAGE i000 WITH 'Failure'.
ENDIF.
ELSE.
MESSAGE i000 WITH 'Cancled'.
ENDIF.
ENDFORM. " EXCEL_FORM_DOWNLOAD
*&---------------------------------------------------------------------*
*& Form CONVERT_CURRENCY
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_BUDAT text
* -->P_FCURR text
* -->P_LCURR text
* -->P_FAMT text
* -->P_LAMT text
*----------------------------------------------------------------------*
FORM convert_currency USING p_budat p_fcurr p_lcurr
p_famt p_lamt.
IF p_fcurr = p_lcurr.
p_lamt = p_famt.
ELSE.
CALL FUNCTION 'CONVERT_TO_LOCAL_CURRENCY'
EXPORTING
client = sy-mandt
date = p_budat
foreign_currency = p_fcurr
foreign_amount = p_famt
local_currency = p_lcurr
IMPORTING
local_amount = p_lamt
EXCEPTIONS
no_rate_found = 01.
ENDIF.
ENDFORM. "CONVERT_CURRENCY
*&---------------------------------------------------------------------*
*& Form CONVERT_CHAR_TO_AMT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_VALUE text
* -->P_WAERS text
* -->P_AMT text
*----------------------------------------------------------------------*
FORM convert_char_to_amt USING p_value p_waers p_amt.
DATA : lv_amt(20) TYPE c.
DATA : lv_ext TYPE bapicurr-bapicurr.
CALL FUNCTION 'STRING_REPLACE'
EXPORTING
pattern = ','
substitute = ''
CHANGING
text = p_value.
IF sy-subrc NE 0.
ENDIF.
lv_ext = p_value.
CALL FUNCTION 'BAPI_CURRENCY_CONV_TO_INTERNAL'
EXPORTING
currency = p_waers
amount_external = lv_ext
max_number_of_digits = '11'
IMPORTING
amount_internal = lv_amt.
p_amt = lv_amt.
ENDFORM. "CONVERT_CHAR_TO_AMT
*&---------------------------------------------------------------------*
*& Form F4IF_INT_TABLE_VALUE_REQUEST
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->PT_VALUE_TAB text
* -->PT_FIELD_TAB text
* -->PT_RETURN_TAB text
* -->P_RETFIELD text
* -->P_DYNPROFIELD text
*----------------------------------------------------------------------*
FORM f4if_int_table_value_request TABLES pt_value_tab
pt_field_tab
pt_return_tab STRUCTURE ddshretval
USING p_retfield TYPE dfies-fieldname
p_dynprofield TYPE help_info-dynprofld.
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
retfield = p_retfield
dynpprog = sy-cprog
dynpnr = sy-dynnr
dynprofield = p_dynprofield
value_org = 'S'
* display = 'X'
TABLES
value_tab = pt_value_tab
field_tab = pt_field_tab
return_tab = pt_return_tab
EXCEPTIONS
parameter_error = 1
no_values_found = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDFORM. " f4if_int_table_value_request
*&---------------------------------------------------------------------*
*& Form POPUP_TO_CONFIRM_02
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->PV_TITLE text
* -->PV_QUESTION1 text
* -->PV_QUESTION2 text
* -->PV_ANSWER text
*----------------------------------------------------------------------*
FORM popup_to_confirm_02 USING pv_title
pv_question1
pv_question2
CHANGING pv_answer.
CALL FUNCTION 'POPUP_TO_CONFIRM_STEP'
EXPORTING
textline1 = pv_question1
textline2 = pv_question2
titel = pv_title
IMPORTING
answer = pv_answer. " J:예 N:아니오 A:취소
ENDFORM. " POPUP_TO_CONFIRM
*&---------------------------------------------------------------------*
*& Form POPUP_TO_CONFIRM
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_TITLE text
* -->P_TEXT text
* -->P_DEFAULT text
* -->P_CANC text
* -->P_ANSWER text
*----------------------------------------------------------------------*
FORM popup_to_confirm USING p_title
p_text
p_default
p_canc
CHANGING p_answer.
CALL FUNCTION 'POPUP_TO_CONFIRM'
EXPORTING
titlebar = p_title
text_question = p_text
text_button_1 = 'Yes'
text_button_2 = 'No'
default_button = p_default
display_cancel_button = p_canc
IMPORTING
answer = p_answer
EXCEPTIONS
text_not_found = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
CLEAR p_answer.
ENDIF.
ENDFORM. " POPUP_TO_CONFIRM
*&---------------------------------------------------------------------*
*& Form GET_LAST_DAY
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_DATE text
* -->P_LAST_DATE text
*----------------------------------------------------------------------*
FORM get_last_day USING p_date
CHANGING p_last_date.
"월의 마지막날 구하는 function.
CALL FUNCTION 'RP_LAST_DAY_OF_MONTHS'
EXPORTING
day_in = p_date
IMPORTING
last_day_of_month = p_last_date.
ENDFORM. " CHECK_VALIDATION
*&---------------------------------------------------------------------*
*& Form SET_DSMOD
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->PA_DSMOD text
*----------------------------------------------------------------------*
FORM set_dsmod USING pa_dsmod.
TRANSLATE pa_dsmod TO UPPER CASE.
IF pa_dsmod NA 'AEN'.
MESSAGE s000 DISPLAY LIKE 'E' WITH 'BDC Mode Fail'.
LEAVE LIST-PROCESSING.
ENDIF.
ENDFORM. " SET_DSMOD
*&---------------------------------------------------------------------*
*& Form FILE_EXISTS
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_FNAME text
* -->P_EXISTS text
*----------------------------------------------------------------------*
FORM file_exists USING p_fname p_exists.
DATA : l_result TYPE abap_bool.
DATA : l_filenm TYPE string.
CLEAR : p_exists.
p_exists = abap_false.
CHECK p_fname IS NOT INITIAL.
l_filenm = p_fname.
CALL METHOD cl_gui_frontend_services=>file_exist
EXPORTING
file = l_filenm
RECEIVING
result = l_result
EXCEPTIONS
cntl_error = 1
error_no_gui = 2
wrong_parameter = 3
not_supported_by_gui = 4
OTHERS = 5.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
p_exists = l_result.
ENDFORM. "FILE_EXISTS
*&---------------------------------------------------------------------*
*& Form AMT_CONV_TO_INTERNAL
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_WAERS text
* -->P_AMOUNT text
*----------------------------------------------------------------------*
FORM amt_conv_to_internal USING p_waers
CHANGING p_amount.
DATA: l_internal TYPE bapicurr-bapicurr.
l_internal = p_amount.
CALL FUNCTION 'BAPI_CURRENCY_CONV_TO_INTERNAL'
EXPORTING
currency = p_waers
amount_external = l_internal
max_number_of_digits = 22
IMPORTING
amount_internal = l_internal.
p_amount = l_internal.
ENDFORM. "amt_conv_to_external
*&---------------------------------------------------------------------*
*& Form GET_NEXT_NUMBER
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_NRRANG text
* -->P_OBJECT text
* -->P_DOCNO text
*----------------------------------------------------------------------*
FORM get_next_number USING p_nrrang p_object
CHANGING p_docno.
DATA : lv_fldnam TYPE string,
lv_nrrang LIKE inrdp-nrrangenr,
lv_object LIKE nriv-object.
lv_nrrang = p_nrrang.
lv_object = p_object.
CALL FUNCTION 'NUMBER_GET_NEXT'
EXPORTING
nr_range_nr = lv_nrrang
object = lv_object
IMPORTING
number = p_docno
EXCEPTIONS
interval_not_found = 1
number_range_not_intern = 2
object_not_found = 3
quantity_is_0 = 4
quantity_is_not_1 = 5
interval_overflow = 6
buffer_overflow = 7
OTHERS = 8.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
CLEAR p_docno.
ENDIF.
ENDFORM. " F_GET_NEXT_NUMBER
*&---------------------------------------------------------------------*
*& Form GET_NEXT_NUMBER_YEAR
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_NRRANG text
* -->P_OBJECT text
* -->P_YEAR text
* -->P_DOCNO text
*----------------------------------------------------------------------*
FORM get_next_number_year USING p_nrrang p_object p_year
CHANGING p_docno.
DATA : lv_fldnam TYPE string,
lv_nrrang LIKE inrdp-nrrangenr,
lv_object LIKE nriv-object,
lv_year LIKE inri-toyear.
lv_nrrang = p_nrrang.
lv_object = p_object.
IF p_year IS NOT INITIAL.
lv_year = p_year.
ELSE.
lv_year = '0000'.
ENDIF.
CALL FUNCTION 'NUMBER_GET_NEXT'
EXPORTING
nr_range_nr = lv_nrrang
object = lv_object
toyear = lv_year
IMPORTING
number = p_docno
EXCEPTIONS
interval_not_found = 1
number_range_not_intern = 2
object_not_found = 3
quantity_is_0 = 4
quantity_is_not_1 = 5
interval_overflow = 6
buffer_overflow = 7
OTHERS = 8.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
CLEAR p_docno.
ENDIF.
ENDFORM. " F_GET_NEXT_NUMBER_YEAR
*&---------------------------------------------------------------------*
*& Form GET_VALUE_LIST_DOM
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_TAB text
* -->P_DOMAIN text
*----------------------------------------------------------------------*
FORM get_value_list_dom TABLES p_tab
USING p_domain.
SELECT domvalue_l ddtext
INTO TABLE p_tab
FROM dd07t
WHERE domname EQ p_domain
AND ddlanguage EQ sy-langu
AND as4local EQ 'A'.
IF sy-subrc EQ 0.
SORT p_tab.
ELSE.
REFRESH p_tab.
ENDIF.
ENDFORM. " GET_VALUE_LIST_DOM
*&---------------------------------------------------------------------*
*& Form get_value_text
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_TAB text
* -->P_DOMAIN text
*----------------------------------------------------------------------*
FORM get_value_text USING p_domain
p_value
CHANGING p_text.
SELECT SINGLE ddtext
INTO p_text
FROM dd07t
WHERE domname EQ p_domain
AND ddlanguage EQ sy-langu
AND as4local EQ 'A'
AND domvalue_l EQ p_value.
ENDFORM. " get_value_text
*&---------------------------------------------------------------------*
*& Form GET_DOM_TEXT_LIST
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_DOMNA text
*----------------------------------------------------------------------*
FORM get_dom_text_list USING p_domna.
SELECT domname domvalue_l ddtext
APPENDING TABLE gt_domain
FROM dd07t
WHERE domname = p_domna
AND ddlanguage = sy-langu
AND as4local = 'A'.
SORT : gt_domain.
ENDFORM. " GET_DOM_TEXT_LIST
*&---------------------------------------------------------------------*
*& Form GET_FILE_PATH
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_FILENM text
*----------------------------------------------------------------------*
FORM get_file_path CHANGING p_filenm.
DATA: line_count TYPE i,
user_action TYPE i,
rtn_code LIKE sy-subrc,
lt_filetable TYPE filetable,
ls_filetable TYPE file_table.
CALL METHOD cl_gui_frontend_services=>file_open_dialog
EXPORTING
window_title = 'Upload'
multiselection = ' '
default_extension = 'XLS'
default_filename = ' '
file_filter = '*.XLS'
CHANGING
file_table = lt_filetable
rc = rtn_code
user_action = user_action.
CALL METHOD cl_gui_cfw=>flush.
CASE user_action.
WHEN cl_gui_frontend_services=>action_ok.
READ TABLE lt_filetable INTO ls_filetable INDEX 1.
CHECK sy-subrc IS INITIAL.
MOVE: ls_filetable-filename TO p_filenm.
WHEN cl_gui_frontend_services=>action_cancel.
ENDCASE.
ENDFORM. " GET_FILE_PATH
*&---------------------------------------------------------------------*
*& Form CHK_FILE_PATH
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_FNAME text
*----------------------------------------------------------------------*
FORM chk_file_path USING p_fname.
DATA: lv_result TYPE char1,
lv_file TYPE string.
MOVE: p_fname TO lv_file.
CALL METHOD cl_gui_frontend_services=>file_exist
EXPORTING
file = lv_file
RECEIVING
result = lv_result.
IF NOT sy-subrc IS INITIAL.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ELSEIF lv_result IS INITIAL.
MESSAGE s001(00) WITH 'Please check your file path'.
LEAVE LIST-PROCESSING.
ENDIF.
ENDFORM. " CHK_FILE_PATH
*&---------------------------------------------------------------------*
*& Form SET_BUTTON_100
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_NO text
* -->P_ICON text
* -->P_TEXT text
*----------------------------------------------------------------------*
FORM set_button_100 USING p_no TYPE numc2
p_icon p_text.
DATA : ls_functxt TYPE smp_dyntxt,
lv_fieldname(30).
FIELD-SYMBOLS <fs_func> LIKE sscrfields-functxt_01.
CONCATENATE 'SSCRFIELDS-FUNCTXT_' p_no INTO lv_fieldname.
ASSIGN (lv_fieldname) TO <fs_func>.
IF p_icon EQ space.
MOVE p_text TO <fs_func> .
ELSE.
ls_functxt-icon_id = p_icon.
ls_functxt-icon_text = p_text.
<fs_func> = ls_functxt.
ENDIF.
ENDFORM. " SET_BUTTON_100
*&---------------------------------------------------------------------*
*& Form GET_DYNP_VALUES_READ
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_FIELD text
*----------------------------------------------------------------------*
FORM get_dynp_values_read USING p_field.
DATA : lt_dynpfields TYPE TABLE OF dynpread,
ls_dynpfields TYPE dynpread,
lv_dyname TYPE sy-repid,
lv_dynum TYPE sy-dynnr.
FIELD-SYMBOLS <fs_field> TYPE any.
lv_dyname = sy-repid.
lv_dynum = sy-dynnr.
ls_dynpfields-fieldname = p_field.
APPEND ls_dynpfields TO lt_dynpfields.
CALL FUNCTION 'DYNP_VALUES_READ'
EXPORTING
dyname = lv_dyname
dynumb = lv_dynum
TABLES
dynpfields = lt_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.
EXIT.
ELSE.
READ TABLE lt_dynpfields INTO ls_dynpfields
WITH KEY fieldname = p_field.
IF sy-subrc EQ 0.
ASSIGN (p_field) TO <fs_field>.
IF <fs_field> IS ASSIGNED.
<fs_field> = ls_dynpfields-fieldvalue.
ENDIF.
ENDIF.
ENDIF.
ENDFORM. " GET_DYNP_VALUES_READ
*&---------------------------------------------------------------------*
*& Form SET_DYNP_VALUES
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_FIELD text
*----------------------------------------------------------------------*
FORM set_dynp_values USING p_field.
DATA : lt_dynpfields TYPE TABLE OF dynpread,
ls_dynpfields TYPE dynpread,
lv_dyname TYPE sy-repid,
lv_dynum TYPE sy-dynnr.
FIELD-SYMBOLS <fs_field> TYPE any.
lv_dyname = sy-repid.
lv_dynum = sy-dynnr.
ls_dynpfields-fieldname = p_field.
ASSIGN (p_field) TO <fs_field>.
IF <fs_field> IS ASSIGNED.
ls_dynpfields-fieldvalue = <fs_field>.
ENDIF.
APPEND ls_dynpfields TO lt_dynpfields.
CALL FUNCTION 'DYNP_VALUES_UPDATE'
EXPORTING
dyname = lv_dyname
dynumb = lv_dynum
TABLES
dynpfields = lt_dynpfields
EXCEPTIONS
invalid_abapworkarea = 1
invalid_dynprofield = 2
invalid_dynproname = 3
invalid_dynpronummer = 4
invalid_request = 5
no_fielddescription = 6
undefind_error = 7
OTHERS = 8.
IF sy-subrc <> 0.
EXIT.
ENDIF.
ENDFORM. " SET_DYNP_VALUES
*&---------------------------------------------------------------------*
*& Form SET_BTN_1000
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_0139 text
* -->P_ICON_XXL text
* -->P_0141 text
*----------------------------------------------------------------------*
FORM set_btn_1000 USING p_no TYPE numc2
p_icon p_text.
DATA : ls_functxt TYPE smp_dyntxt,
lv_fieldname(30).
FIELD-SYMBOLS <fs_func> LIKE sscrfields-functxt_01.
CONCATENATE 'SSCRFIELDS-FUNCTXT_' p_no INTO lv_fieldname.
ASSIGN (lv_fieldname) TO <fs_func>.
IF p_icon EQ space.
MOVE p_text TO <fs_func> .
ELSE.
ls_functxt-icon_id = p_icon.
ls_functxt-icon_text = p_text.
<fs_func> = ls_functxt.
ENDIF.
ENDFORM. " SET_BTN_1000
*&---------------------------------------------------------------------*
*& Form F_PDF_DOWNLOAD
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_JOB text
*----------------------------------------------------------------------*
FORM f_pdf_download USING p_job TYPE ssfcrescl.
DATA : lv_transfer_bin TYPE sx_boolean,
lt_content_txt TYPE soli_tab,
lt_content_bin TYPE solix_tab,
lt_objhead TYPE soli_tab,
lv_len_in LIKE sood-objlen,
ls_otf TYPE solisti1,
lv_bin_filesize TYPE i,
lv_bin_file TYPE xstring,
lt_lines LIKE tline OCCURS 0 WITH HEADER LINE.
DATA : lv_filesize TYPE i,
lv_filename TYPE string.
DATA : lt_otf TYPE TABLE OF itcoo WITH HEADER LINE.
lt_otf[] = p_job-otfdata.
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
format = 'PDF'
IMPORTING
bin_filesize = lv_bin_filesize
bin_file = lv_bin_file
TABLES
otf = lt_otf
lines = lt_lines
EXCEPTIONS
err_max_linewidth = 1
err_format = 2
err_conv_not_possible = 3
err_bad_otf = 4
OTHERS = 5.
LOOP AT lt_otf.
CONCATENATE lt_otf-tdprintcom lt_otf-tdprintpar INTO ls_otf.
APPEND ls_otf TO lt_content_txt.
ENDLOOP.
CALL FUNCTION 'SX_OBJECT_CONVERT_OTF_PDF'
EXPORTING
format_src = 'OTF'
format_dst = 'PDF'
devtype = 'PRINTER'
CHANGING
transfer_bin = lv_transfer_bin
content_txt = lt_content_txt
content_bin = lt_content_bin
objhead = lt_objhead
len = lv_len_in
EXCEPTIONS
err_conv_failed = 1
OTHERS = 2.
* pdf 다운로드
lv_filesize = lv_len_in.
PERFORM open_save_file_sel USING 'pdf' CHANGING lv_filename.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
bin_filesize = lv_filesize
filename = lv_filename
filetype = 'BIN'
TABLES
data_tab = lt_content_bin.
ENDFORM. " F_PDF_DOWNLOAD
*&---------------------------------------------------------------------*
*& Form OPEN_SAVE_FILE_SEL
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_EXT text
* -->P_FILENAME text
*----------------------------------------------------------------------*
FORM open_save_file_sel USING p_ext CHANGING p_filename.
DATA: lv_subrc LIKE sy-subrc,
lv_has_field_separator TYPE char01,
lv_filename TYPE string,
lv_path TYPE string,
lv_fullpath TYPE string,
lv_default_extension TYPE string,
lv_file_filter TYPE string,
lv_initial_directory TYPE string,
lv_default_file_name TYPE string,
lt_file_table TYPE filetable,
ls_file_table TYPE LINE OF filetable,
lv_user_action TYPE i.
CLEAR p_filename.
lv_default_extension = p_ext.
CONCATENATE '*.' p_ext INTO lv_default_file_name.
lv_initial_directory = 'C:\'.
CONCATENATE cl_gui_frontend_services=>filetype_all
* CL_GUI_FRONTEND_SERVICES=>FILETYPE_TEXT
cl_gui_frontend_services=>filetype_excel
INTO lv_file_filter.
CALL METHOD cl_gui_frontend_services=>file_save_dialog
EXPORTING
* WINDOW_TITLE
default_extension = lv_default_extension
default_file_name = lv_default_file_name
* WITH_ENCODING = ABAP_TRUE
file_filter = lv_file_filter
initial_directory = lv_initial_directory
CHANGING
filename = lv_filename
path = lv_path
fullpath = lv_fullpath
user_action = lv_user_action
EXCEPTIONS
cntl_error = 2
error_no_gui = 3
not_supported_by_gui = 4
OTHERS = 5.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
EXIT.
ELSE.
IF lv_user_action NE cl_gui_frontend_services=>action_ok.
EXIT.
ENDIF.
p_filename = lv_filename.
ENDIF.
ENDFORM. " OPEN_SAVE_FILE_SEL
*&---------------------------------------------------------------------*
*& Form ALSMEX_TAB_TO_ITAB
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->PT_INTERN text
* -->PT_EXCEL_TABLE text
* -->PS_EXCEL_STRUC text
*----------------------------------------------------------------------*
*FORM ALSMEX_TAB_TO_ITAB
* TABLES PT_INTERN STRUCTURE ALSMEX_TABLINE
* USING PT_EXCEL_TABLE PS_EXCEL_STRUC.
* FIELD-SYMBOLS : <FIELD> TYPE ANY.
* FIELD-SYMBOLS : <ITAB> TYPE STANDARD TABLE.
* FIELD-SYMBOLS : <ILINE> TYPE ANY.
*
* ASSIGN : (PT_EXCEL_TABLE) TO <ITAB>.
* ASSIGN : (PS_EXCEL_STRUC) TO <ILINE>.
*
* LOOP AT PT_INTERN.
* AT NEW ROW.
* CLEAR : <ILINE>.
* ENDAT.
*
* ASSIGN COMPONENT PT_INTERN-COL OF STRUCTURE <ILINE> TO <FIELD>.
*
* IF PT_INTERN-VALUE CO '0123456789,.- '.
* REPLACE ALL OCCURRENCES OF ',' IN PT_INTERN-VALUE WITH ''.
* ENDIF.
*
* MOVE PT_INTERN-VALUE TO <FIELD>.
*
* AT END OF ROW.
* APPEND <ILINE> TO <ITAB>.
* ENDAT.
* ENDLOOP.
*
*ENDFORM. " ALSMEX_TAB_TO_ITAB
**&---------------------------------------------------------------------*
**& Form START_INTERFACE_BDC
**&---------------------------------------------------------------------*
** text
**----------------------------------------------------------------------*
** -->P_MODE text
**----------------------------------------------------------------------*
*FORM START_INTERFACE_BDC USING P_MODE.
* CLEAR : FTPOST, FTPOST[].
* CLEAR : FTTAX, FTTAX[].
* CLEAR : BLNTAB, BLNTAB[].
* CLEAR : GV_FTPOST_TYPE.
* CLEAR : GV_FTPOST_CNT.
*
* CALL FUNCTION 'POSTING_INTERFACE_START'
* EXPORTING
* I_FUNCTION = 'C' " Using Call Transaction
* I_KEEP = 'Y'
* I_MODE = P_MODE
* I_UPDATE = 'S'
* EXCEPTIONS
* CLIENT_INCORRECT = 1
* FUNCTION_INVALID = 2
* GROUP_NAME_MISSING = 3
* MODE_INVALID = 4
* UPDATE_INVALID = 5
* OTHERS = 6.
*ENDFORM. " START_BDC
*
**&---------------------------------------------------------------------*
**& Form END_INTERFACE_BDC
**&---------------------------------------------------------------------*
** text
**----------------------------------------------------------------------*
*FORM END_INTERFACE_BDC.
* CALL FUNCTION 'POSTING_INTERFACE_END'
* EXPORTING
* I_BDCIMMED = 'X'.
*
* CLEAR : FTPOST, FTPOST[].
* CLEAR : FTTAX, FTTAX[].
* CLEAR : BLNTAB, BLNTAB[].
* CLEAR : GV_FTPOST_TYPE.
* CLEAR : GV_FTPOST_CNT.
*ENDFORM. "END_BDC
*&---------------------------------------------------------------------*
*& Form FILL_FIELD
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->FNAM text
* -->FVAL text
*----------------------------------------------------------------------*
FORM fill_field USING fnam fval fcurr_x.
"USING 'BSEG-WRBTR' GT_DATA-WRBTR_D 'X'.
DATA : lv_curr(15) TYPE c.
CHECK fval NE space.
ftpost-fnam = fnam.
ftpost-stype = gv_ftpost_type.
ftpost-count = gv_ftpost_cnt.
" 금액 필드일 경우.
IF fcurr_x = 'X'.
WRITE fval TO lv_curr CURRENCY
gv_ftpost_waers LEFT-JUSTIFIED.
CONDENSE lv_curr NO-GAPS.
WRITE lv_curr TO ftpost-fval.
ELSE.
WRITE fval TO ftpost-fval.
ENDIF.
APPEND ftpost.
CLEAR ftpost.
ENDFORM. "BUCHEN_FELD
*&---------------------------------------------------------------------*
*& Form BUILD_MESSGE_IF
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->PS_MESSAGE text
* -->PV_TEXT text
*----------------------------------------------------------------------*
FORM build_messge_if USING ps_message
STRUCTURE gt_if_msg CHANGING pv_text.
CLEAR pv_text.
CALL FUNCTION 'MESSAGE_TEXT_BUILD'
EXPORTING
msgid = ps_message-msgid
msgnr = ps_message-msgno
msgv1 = ps_message-msgv1
msgv2 = ps_message-msgv2
msgv3 = ps_message-msgv3
msgv4 = ps_message-msgv4
IMPORTING
message_text_output = pv_text.
ENDFORM. "BUILD_MESSGE_IF
*&---------------------------------------------------------------------*
*& Form GET_POST_PERIOD
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->PV_DATE text
* -->P_LFGJA text
* -->P_LFMON text
*----------------------------------------------------------------------*
FORM get_post_period USING pv_bukrs pv_date LIKE sy-datum
CHANGING p_lfgja p_lfmon.
CLEAR : p_lfgja, p_lfmon.
CALL FUNCTION 'FI_PERIOD_DETERMINE'
EXPORTING
i_bukrs = pv_bukrs
i_budat = pv_date
IMPORTING
e_gjahr = p_lfgja
e_monat = p_lfmon
EXCEPTIONS
fiscal_year = 1
period = 2
period_version = 3
posting_period = 4
special_period = 5
version = 6
posting_date = 7
OTHERS = 8.
IF sy-subrc NE 0.
p_lfgja = pv_date(4).
p_lfmon = pv_date+4(2).
ENDIF.
ENDFORM. "GET_POST_PERIOD
*&---------------------------------------------------------------------*
*& Form GET_KOKRS_TXT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_KOKRS text
* -->P_BEZEI text
*----------------------------------------------------------------------*
FORM set_kokrs_base USING p_kokrs.
SELECT SINGLE bezei ktopl
INTO (gv_kbezei_cm, gv_ktopl_cm)
FROM tka01
WHERE kokrs = p_kokrs.
ENDFORM. "GET_KOKRS_TXT
*&---------------------------------------------------------------------*
*& Form CONV_DB_WAERS
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_VALUE text
*----------------------------------------------------------------------*
FORM conv_db_waers USING p_value p_waers.
CALL FUNCTION 'CURRENCY_AMOUNT_IDOC_TO_SAP'
EXPORTING
currency = p_waers
idoc_amount = p_value
IMPORTING
sap_amount = p_value.
ENDFORM. "TO_KRW
*&---------------------------------------------------------------------*
*& Form CONV_VIEW_WAERS
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_VALUE text
* -->P_WAERS text
* -->P_DOC_VALUE text
*----------------------------------------------------------------------*
FORM conv_view_waers USING p_value p_waers
CHANGING p_doc_value.
CALL FUNCTION 'CURRENCY_AMOUNT_SAP_TO_IDOC'
EXPORTING
currency = p_waers
sap_amount = p_value
IMPORTING
idoc_amount = p_doc_value.
ENDFORM. "TO_KRW
*&---------------------------------------------------------------------*
*& Form CONVERT_1000
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_VALUE text
* -->P_VALUE_1000 text
*----------------------------------------------------------------------*
*FORM CONVERT_1000_U USING P_VALUE
* CHANGING P_VALUE_1000.
* P_VALUE_1000 = P_VALUE * 1000.
*ENDFORM. "CONVERT_1000
*&---------------------------------------------------------------------*
*& Form CONVERT_1000_D
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_VALUE text
* -->P_VALUE_1000 text
*----------------------------------------------------------------------*
*FORM CONVERT_1000_D USING P_VALUE
* CHANGING P_VALUE_1000.
* P_VALUE_1000 = P_VALUE / 1000.
*ENDFORM. "CONVERT_1000
*&---------------------------------------------------------------------*
*& Form GET_VERSN_TEXT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_KOKRS text
* -->P_VERSN text
* -->P_VERSN_TXT text
*----------------------------------------------------------------------*
*FORM GET_VERSN_TEXT USING P_KOKRS P_VERSN
* CHANGING P_VERSN_TXT.
* CLEAR : P_VERSN_TXT.
* SELECT SINGLE TXT
* INTO P_VERSN_TXT
* FROM TKT09
* WHERE KOKRS = P_KOKRS
* AND VERSN = P_VERSN
* AND LANGU = SY-LANGU.
*ENDFORM. "GET_VERSN_TEXT
*&---------------------------------------------------------------------*
*& Form UPLOAD_XLS_STRUCT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_TABLE text
* -->P_FILE text
* -->P_SCOL text
* -->P_SROW text
* -->P_ECOL text
* -->P_EROW text
*----------------------------------------------------------------------*
FORM upload_xls_struct TABLES p_table
USING p_file
p_scol
p_srow
p_ecol
p_erow.
DATA : lt_intern TYPE alsmex_tabline OCCURS 0 WITH HEADER LINE.
DATA : lv_index TYPE i.
FIELD-SYMBOLS : <fs_line>.
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
filename = p_file
i_begin_col = p_scol
i_begin_row = p_srow
i_end_col = p_ecol
i_end_row = p_erow
TABLES
intern = lt_intern
EXCEPTIONS
inconsistent_parameters = 1
upload_ole = 2
OTHERS = 3.
IF sy-subrc <> 0.
FORMAT COLOR COL_BACKGROUND INTENSIFIED.
WRITE:/ 'Error Uploading file'.
EXIT.
ENDIF.
IF lt_intern[] IS INITIAL.
FORMAT COLOR COL_BACKGROUND INTENSIFIED.
WRITE:/ 'No Data Uploaded'.
EXIT.
ELSE.
SORT lt_intern BY row col.
LOOP AT lt_intern.
MOVE lt_intern-col TO lv_index.
ASSIGN COMPONENT lv_index OF STRUCTURE p_table TO <fs_line>.
IF lt_intern-value CO '0123456789,.- '.
REPLACE ALL OCCURRENCES OF ',' IN lt_intern-value WITH ''.
ENDIF.
MOVE lt_intern-value TO <fs_line>.
AT END OF row.
APPEND p_table.
CLEAR p_table.
ENDAT.
ENDLOOP.
ENDIF.
ENDFORM. "UPLOAD_EXCEL_FILE
*&---------------------------------------------------------------------*
*& Form SET_PREV_MONTH
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_P_GJAHR text
* -->P_P_PERDE text
*----------------------------------------------------------------------*
FORM set_prev_month USING pv_gjahr
pv_perde.
DATA : lv_date LIKE sy-datum.
CALL FUNCTION 'RP_CALC_DATE_IN_INTERVAL'
EXPORTING
date = sy-datum
days = '00'
months = '01'
signum = '-'
years = '00'
IMPORTING
calc_date = lv_date.
pv_gjahr = lv_date+0(4).
pv_perde = lv_date+4(2).
ENDFORM. " SET_PREV_MONTH
*&---------------------------------------------------------------------*
*& Form GET_CSKT_KTEXT
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
* -->P_GS_ZTFICD10_ACC_CD text
* <--P_GS_ZTFICD10_KTEXT text
*&---------------------------------------------------------------------*
FORM get_cskt_ktext USING pv_kostl
CHANGING pv_ktext.
SELECT SINGLE ktext
INTO pv_ktext
FROM cskt
WHERE spras EQ '3'
AND kokrs EQ '1000'
AND kostl EQ pv_kostl
AND datbi EQ '99991231'.
ENDFORM.
피드 구독하기:
글 (Atom)