Sap/abap dialog box’tan .txt dosyası yüklenmesi

Merhabalar arkadaşlar,

Sap sistemi için abap kodunu kullanarak  txt dosyasının upload etmemizi sağlayan kodu

sizlerle paylaşacağım, sap sisteminden se38 transaction kodumuzla yeni bir  kod sayfası açıyoruz.

 

*&———————————————————————*
*& Report ZFOB_ABC_DONEMSELLESTIRME
*&
*&———————————————————————*
*&
*&
*&———————————————————————*

REPORT zfob_sutas_donemsellestirme.

TYPE-POOLS : slis,ACEDS.

*———————————————————————-*
* I N T E R N A L T A B L E S *
*———————————————————————-*
DATA: BEGIN OF gt_main OCCURS 0,
ACRTYPE like ACEDS_ACCOUNTS_EXT-ACRTYPE ,
ACCRULE like ACEDS_ACCOUNTS_EXT-ACCRULE ,
START_ACCNT like ACEDS_ACCOUNTS_EXT-INC_START_ACCNT ,
TARGET_ACCNT like ACEDS_ACCOUNTS_EXT-INC_TARGET_ACCNT,
DOC_TYPE like ACEDS_ACCOUNTS_EXT-INC_DOC_TYPE ,

BUKRS like ACAC_OBJECT_HEADER_EXT-BUKRS ,
ACAC_OBJTYPE like ACAC_OBJECT_HEADER_EXT-ACAC_OBJTYPE,
DATE_FROM like ACAC_OBJECT_HEADER_EXT-DATE_FROM ,
TEXT like ACAC_OBJECT_HEADER_EXT-TEXT ,
VALITY_FROM like ACAC_OBJECT_HEADER_EXT-VALITY_FROM ,
VALITY_TO like ACAC_OBJECT_HEADER_EXT-VALITY_TO ,

END OF gt_main.

DATA: gt_send LIKE gt_main.
*———————————————————————-*
* V A R I A B L E S *
*———————————————————————-*
*DATA :my_is_obj_subkey TYPE ace_object_subkey_int,
* my_id_ref_subkey TYPE ace_ref_subkey,
* my_it_ps_items_new TYPE aceps_object_item_ext_t,
* my_id_effdate TYPE sy-datum,
* my_is_post_params TYPE aceps_manual_posting_params,
* my_et_docitems TYPE aceps_ace_doc_extended_t,
* my_et_return TYPE bapiret2_t,
* my_et_acedoc_return TYPE ace_acedoc_return_t,
* my_et_accdoc_return TYPE ace_accdoc_return_t.

DATA :gt_fcat TYPE slis_t_fieldcat_alv,
gs_fcat LIKE LINE OF gt_fcat,
gs_layout TYPE slis_layout_alv,
gs_variant TYPE disvariant ,
gs_is_grid TYPE lvc_s_glay,
gs_event TYPE slis_t_event,
gs_event_exit TYPE slis_t_event_exit,
gt_sort TYPE slis_t_sortinfo_alv,
gs_sort LIKE LINE OF gt_sort.

*———————————————————————-*
* P R O G R A M S T A R T *
*———————————————————————-*
START-OF-SELECTION.

PERFORM get_data.
*———————————————————————-*
* E N D O F S E L E C T I O N *
*———————————————————————-*
END-OF-SELECTION.

PERFORM fiil_fcat.
PERFORM display_alv.
*&———————————————————————*
*& Form GET_DATA
*&———————————————————————*
* text
*———————————————————————-*
* –> p1 text
* <– p2 text
*———————————————————————-*
FORM get_data .

TYPES: BEGIN OF itab_file,
rec(500) TYPE c,
END OF itab_file.

DATA: l_input_file TYPE string.
DATA : rec_line(500).
DATA : f_tab TYPE TABLE OF itab_file.

DATA : l_path TYPE string,
l_name TYPE string,
l_act type i .
CALL FUNCTION ‘GUI_FILE_LOAD_DIALOG’
IMPORTING
filename = l_name
path = l_path
USER_ACTION = l_act.

IF SY-SUBRC = 0 and L_ACT is initial.
CONDENSE l_path.
CONDENSE l_name.
CONCATENATE l_path l_name INTO l_input_file.
endif.

check not l_input_file is INITIAL.

CALL METHOD cl_gui_frontend_services=>gui_upload
EXPORTING
filename = l_input_file
CHANGING
data_tab = f_tab
EXCEPTIONS
OTHERS = 1.
IF sy-subrc <> 0.
RAISE export_error.
ENDIF.

LOOP AT f_tab INTO gt_main.
APPEND gt_main.
ENDLOOP.

ENDFORM. ” GET_DATA
*&———————————————————————*
*& Form FIIL_FCAT
*&———————————————————————*
* text
*———————————————————————-*
* –> p1 text
* <– p2 text
*———————————————————————-*
FORM fiil_fcat .

CALL FUNCTION ‘REUSE_ALV_FIELDCATALOG_MERGE’
EXPORTING
i_program_name = sy-repid
i_internal_tabname = ‘GT_MAIN’
i_inclname = sy-repid
CHANGING
ct_fieldcat = gt_fcat.
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. ” FIIL_FCAT
*&———————————————————————*
*& Form DISPLAY_ALV
*&———————————————————————*
* text
*———————————————————————-*
* –> p1 text
* <– p2 text
*———————————————————————-*
FORM display_alv .

CALL FUNCTION ‘REUSE_ALV_GRID_DISPLAY’
EXPORTING
it_fieldcat = gt_fcat[]
i_callback_pf_status_set = ‘SET_PF_STATUS’
i_callback_user_command = ‘USER_COMMAND’
i_callback_program = sy-repid
TABLES
t_outtab = gt_main.

ENDFORM. ” DISPLAY_ALV
*&———————————————————————*
*& Form set_pf_status
*&———————————————————————*
* text
*———————————————————————-*
* –>RT_EXTAB text
*———————————————————————-*
FORM set_pf_status USING rt_extab TYPE slis_t_extab.
DESCRIBE TABLE rt_extab.
SET PF-STATUS ‘STANDARD_FULLSCREEN’.
ENDFORM. “set_pf_status
*&———————————————————————*
*& Form user_command
*&———————————————————————*
* text
*———————————————————————-*
* –>R_UCOMM text
* –>RS_SELFIELD text
*———————————————————————-*
FORM user_command USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
DATA lv_file TYPE string.

IF r_ucomm EQ ‘KAYIT’.

READ TABLE gt_main INDEX rs_selfield-tabindex.
CHECK sy-subrc IS INITIAL.

MOVE-CORRESPONDING gt_main TO gt_send.

PERFORM kayit.

ENDIF.
ENDFORM. “User_command
*&———————————————————————*
*& Form GONDER
*&———————————————————————*
* text
*———————————————————————-*
* –> p1 text
* <– p2 text
*———————————————————————-*
FORM kayit .

* CALL FUNCTION ‘ACEPS1_OBJ_CREATE’
* EXPORTING
* is_obj_subkey = my_is_obj_subkey
* id_ref_subkey = my_id_ref_subkey
* it_ps_items_new = my_it_ps_items_new
* id_effdate = my_id_effdate
* is_post_params = my_is_post_params
* IMPORTING
* et_docitems = my_et_docitems
* et_return = my_et_return
* et_acedoc_return = my_et_acedoc_return
* et_accdoc_return = my_et_accdoc_return.

DATA:
LS_ACAC_OBJECT_KEY TYPE ACAC_OBJECT_KEY_INT,
LS_ACCRUAL_SUBOBJECT TYPE ACE_EX_SUBKEY,
LD_DATA_CREATED TYPE FLAG,
LD_DATA_CHANGED TYPE FLAG,
LD_DATA_DELETED TYPE FLAG,
LT_DOCITEMS TYPE ACEPS_ACE_DOC_EXTENDED_T,
LT_RETURN TYPE BAPIRET2_T,
LT_ACCDOC_RETURN TYPE ACE_ACCDOC_RETURN_T,
LD_OBJ_ERROR TYPE FLAG,
IT_PARAMS TYPE ACEDS_PARAM_T,
IS_ASSIGNMENTS TYPE ACE_ASSIGNMENTS,
IT_ACCOUNTS TYPE ACEDS_ACCOUNTS_T,
ID_KEYDATE TYPE ACE_EFFDATE,
IS_POST_PARAMS TYPE ACEPS_MANUAL_POSTING_PARAMS,
ID_TRANSFER_PURPOSE TYPE ACE_DATA_TRANSFER_PURPOSE,
ID_TESTRUN TYPE FLAG,
CS_OBJECT_HEADER TYPE ACAC_OBJECT_HEADER_EXT,
CT_OBJECT_ITEMS TYPE ACEDS_ITEMS_T.

CALL FUNCTION ‘ACAC_OBJECT_MODIFY_EXT’
EXPORTING
IS_ASSIGNMENTS = IS_ASSIGNMENTS
IT_ACCOUNTS = IT_ACCOUNTS
IT_PARAMS = IT_PARAMS
ID_EFFDATE = ID_KEYDATE
IS_POST_PARAMS = IS_POST_PARAMS
ID_TESTRUN = ID_TESTRUN
IMPORTING
ED_DATA_CREATED = LD_DATA_CREATED
ED_DATA_CHANGED = LD_DATA_CHANGED
ET_DOCITEMS = LT_DOCITEMS
ET_RETURN = LT_RETURN
ET_ACCDOC_RETURN = LT_ACCDOC_RETURN
CHANGING
CS_OBJECT = CS_OBJECT_HEADER
CT_OBJECT_ITEMS = CT_OBJECT_ITEMS.

ENDFORM. ” GONDER

 

 

 

 

Oğuz ALTUNTAŞ  © 2016

 

Bunlarda ilgini çekebilir !