λλ λ°μ΄ν°λ₯Ό μ λ‘λ ν΄μΌ νλ κ²½μ°, μ°μ μ¬μ©μκ° μμ νμΌμ λ°μ΄ν°λ₯Ό μ λ ₯νκ² ν λ€μμ, κ·Έ λ°μ΄ν°λ₯Ό λ°μμ BDCλ BAPIλ‘ μ²λ¦¬νλ€. μ΄λ μ λ‘λ μμμ λͺ¨λ μ¬μ©μλ€μκ² μΌκ΄λκ² μ 곡ν΄μΌ νκΈ° λλ¬Έμ, μ λ‘λ νλ‘κ·Έλ¨μμ ν νλ μμλ μ 곡νλ€.
μ¬λ¬ λ°©λ²μ΄ μμ μλ μκ² μ§λ§, Web Repository(T-code SMW0)λ₯Ό λ§μ΄ μ΄μ©νλ€.
1. Web Repository(T-code SMW0)μ ν νλ μ λ‘λ
- μ μ₯ νμΌλͺ : ZTESTFILE
2. Application Barμ μ λ‘λ λ²νΌ μμ±
3. PAI λͺ¨λμ PERFORM TEMPLATE_DOWNLOAD μμ±
PROCESS AFTER INPUT.
MODULE EXIT_0100 AT EXIT-COMMAND.
MODULE USER_COMMAND_0100.
MODULE USER_COMMAND_0100 INPUT.
CLEAR GV_UCOMM.
GV_UCOMM = GV_OKCODE.
CLEAR GV_OKCODE.
CASE GV_UCOMM.
WHEN 'TEMP'. "GUI Statusμ λ±λ‘ν Function Code
PERFORM TEMPLATE_DOWNLOAD.
ENDCASE.
ENDMODULE.
4. PERFORM TEMPLATE_DOWNLOAD λ‘μ§ κ΅¬ν
FORM TEMPLATE_DOWNLOAD.
DATA LV_SAVEPATH TYPE STRING.
"4-1. μ μ₯μμΉ μ ν
PERFORM SET_SAVE_PATH CHANGING LV_SAVEPATH.
"4-2. Web Repositoryμμ νμΌ μ ν λ° μ μ₯
PERFORM SAVE_TEMPLATE USING LV_SAVEPATH.
ENDFORM.
4-1. μ μ₯ μμΉ μ ν
FORM SET_SAVE_PATH CHANGING PV_SAVEPATH.
DATA : LV_PATH TYPE STRING,
LV_SAVE_FILENAME TYPE STRING.
DATA(LV_FILENAME) = |Template_| & |{ SY-DATUM }| & |.xlsx|.
CL_GUI_FRONTEND_SERVICES=>FILE_SAVE_DIALOG(
EXPORTING
DEFAULT_FILE_NAME = LV_FILENAME
FILE_FILTER = 'Excel files (*.XLS;*.XLSX)|*.XLSX'
INITIAL_DIRECTORY = 'D:\'
CHANGING
FILENAME = LV_SAVE_FILENAME
PATH = LV_PATH
FULLPATH = PV_SAVEPATH
EXCEPTIONS
CNTL_ERROR = 1 " Control error
ERROR_NO_GUI = 2 " No GUI available
NOT_SUPPORTED_BY_GUI = 3 " GUI does not support this
INVALID_DEFAULT_FILE_NAME = 4 " Invalid default file name
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.
ENDFORM.
4-2. Web Repositoryμμ νμΌ μ ν λ° λ‘컬 PCμ μ μ₯
- FUNCTION 'WWWDATA_IMPORT'
λ FUNCTION 'WWWPARAMS_READ'
λ₯Ό μ΄μ©ν΄μ MIME νμ
μΌλ‘ λ°μ΄ν°λ₯Ό κ°μ Έμ¨ λ€μμ, PERFORM 'GUI_DOWNLOAD'
λ₯Ό μ΄μ©νλ λ°©λ²λ μλ€.
- μ΄μ°¨νΌ FUNCTION 'DOWNLOAD_WEB_OBJECT'
μμμ μ 3κ°μ ν¨μλ₯Ό μ΄μ©νκ³ μλ€
FORM SAVE_TEMPLATE USING PV_SAVEPATH.
DATA : LS_WWWDATA TYPE WWWDATATAB,
LV_FILE TYPE RLGRAP-FILENAME.
SELECT SINGLE * INTO CORRESPONDING FIELDS OF LS_WWWDATA
FROM WWWDATA
WHERE OBJID = 'ZTESTFILE'. "1λ²μμ μ μ₯ν νμΌλͺ
CHECK PV_SAVEPATH IS NOT INITIAL.
"PV_SAVEPATHμ νμ
μ STRINGμ΄κ³ , ν¨μμ λ겨주λ λ³μνμ
μ RLGRAP-FILENAMEμ΄κΈ° λλ¬Έμ
"νμ
λ³νμ μν΄ μλμ κ°μ΄ κ°μ μ λ¬ν΄μ€λ€.
LV_FILE = PV_SAVEPATH.
CALL FUNCTION 'DOWNLOAD_WEB_OBJECT'
EXPORTING
KEY = WWWDATA_ITEM
DESTINATION = LV_FILE.
" λ€μ΄λ‘λ λ°μ λ€μ λ°λ‘ νμΌμ μ€νμν€κ³ μΆλ€λ©΄ μλ ν¨μλ₯Ό μ¬μ©νλ€.
" μ΄λ, DOCUMENT νλΌλ―Έν°λ STRING νμ
μ΄κΈ° λλ¬Έμ LV_FILEμ΄ μλ PV_SAVEPATHλ₯Ό μ΄μ©νλ€.
IF SY-SUBRC = 0.
CL_GUI_FRONTEND_SERVICES=>EXECUTE(
EXPORTING
DOCUMENT = PV_SAVEPATH " Path+Name to Document
OPERATION = 'OPEN' " Reserved: Verb for ShellExecute
EXCEPTIONS
CNTL_ERROR = 1 " Control error
ERROR_NO_GUI = 2 " No GUI available
BAD_PARAMETER = 3 " Incorrect parameter combination
FILE_NOT_FOUND = 4 " File not found
PATH_NOT_FOUND = 5 " Path not found
FILE_EXTENSION_UNKNOWN = 6 " Could not find application for specified extension
ERROR_EXECUTE_FAILED = 7 " Could not execute application or document
SYNCHRONOUS_FAILED = 8 " Cannot Call Application Synchronously
NOT_SUPPORTED_BY_GUI = 9 " GUI does not support this
OTHERS = 10
).
ENDIF.
ENDFORM.
'SAP > ABAP' μΉ΄ν κ³ λ¦¬μ λ€λ₯Έ κΈ
ALV Display β Change ν κΈ λ²νΌ (1) | 2020.12.23 |
---|---|
[ABAP] κΈμ‘ λ³ν - WRITE TO CURRENCY (0) | 2020.12.17 |