REPORT test_report.
tables:pa0008.
data: begin of itab occurs 0 ,
pernr like pa0008-pernr,
ansal like pa0008-ansal,
bet01 like pa0008-bet01 ,
end of itab .
data: v_sum type pa0008-bet01 .
select-options:s_pernr for pa0008-pernr .
start-of-selection .
select pernr
ansal
bet01
from pa0008
into table itab
where pernr in s_pernr .
loop at itab .
at end of pernr .
sum .
write:/ itab-pernr ,
itab-ansal,
itab-bet01.
endat .
endloop.
Here you can find examples and sample programs related to ABAP Report Programs, ALV Grid/List Programs, BDC, HR ABAP, Function Modules, BAPIs, BADIs, Smartforms, SapScripts, etc.
Google Search - Blog...........
ABAP - How To Get Sum For A Particular Field In Classical Reports
REPORT test_report.
tables:pa0008.
data: begin of itab occurs 0 ,
pernr like pa0008-pernr,
ansal like pa0008-ansal,
bet01 like pa0008-bet01 ,
end of itab .
data: v_sum type pa0008-bet01 .
select-options:s_pernr for pa0008-pernr .
start-of-selection .
select pernr
ansal
bet01
from pa0008
into table itab
where pernr in s_pernr .
loop at itab .
v_sum = v_sum + itab-bet01.
at end of pernr .
write:/ itab-pernr ,
itab-ansal,
v_sum.
endat .
endloop.
tables:pa0008.
data: begin of itab occurs 0 ,
pernr like pa0008-pernr,
ansal like pa0008-ansal,
bet01 like pa0008-bet01 ,
end of itab .
data: v_sum type pa0008-bet01 .
select-options:s_pernr for pa0008-pernr .
start-of-selection .
select pernr
ansal
bet01
from pa0008
into table itab
where pernr in s_pernr .
loop at itab .
v_sum = v_sum + itab-bet01.
at end of pernr .
write:/ itab-pernr ,
itab-ansal,
v_sum.
endat .
endloop.
ABAP - Add, Substract Days Or Months Or Years To A Date
REPORT zdates.
parameters:p_date type sy-datum ,
p_days type T5A4A-DLYDY,
p_month type T5A4A-DLYMO,
p_year type T5A4A-DLYYR .
skip.
parameters:add type T5A4A-SPLIT radiobutton group g1 ,
sub type T5A4A-SPLIT radiobutton group g1.
data: calc_date type sy-datum,
days type T5A4A-DLYDY,
months type T5A4A-DLYMO,
years type T5A4A-DLYYR ,
sign type T5A4A-SPLIT .
if add = 'X'.
sign = '+'.
else.
sign = '-'.
endif .
CALL FUNCTION 'RP_CALC_DATE_IN_INTERVAL'
EXPORTING
date = p_date
days = p_days
months = p_month
SIGNUM = sign
years = p_year
IMPORTING
CALC_DATE = CALC_DATE
.
write:/ calc_date .
parameters:p_date type sy-datum ,
p_days type T5A4A-DLYDY,
p_month type T5A4A-DLYMO,
p_year type T5A4A-DLYYR .
skip.
parameters:add type T5A4A-SPLIT radiobutton group g1 ,
sub type T5A4A-SPLIT radiobutton group g1.
data: calc_date type sy-datum,
days type T5A4A-DLYDY,
months type T5A4A-DLYMO,
years type T5A4A-DLYYR ,
sign type T5A4A-SPLIT .
if add = 'X'.
sign = '+'.
else.
sign = '-'.
endif .
CALL FUNCTION 'RP_CALC_DATE_IN_INTERVAL'
EXPORTING
date = p_date
days = p_days
months = p_month
SIGNUM = sign
years = p_year
IMPORTING
CALC_DATE = CALC_DATE
.
write:/ calc_date .
ABAP - Fetch First And Last Date For Any Year
report zdates.
parameters: p_year type T009B-BDATJ.
data: fday type sy-datum ,
lday type sy-datum .
CALL FUNCTION '/IBS/RB_FI_FIRST_LAST_DAY'
EXPORTING
i_gjahr = p_year
i_periv = '01'
IMPORTING
E_FIRST_DAY = fday
E_LAST_DAY = lday
EXCEPTIONS
INPUT_FALSE = 1
T009_NOTFOUND = 2
T009B_NOTFOUND = 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.
write:/ 'this is the first date of the year', fday .
write:/ 'this is the last date of the year', lday .
parameters: p_year type T009B-BDATJ.
data: fday type sy-datum ,
lday type sy-datum .
CALL FUNCTION '/IBS/RB_FI_FIRST_LAST_DAY'
EXPORTING
i_gjahr = p_year
i_periv = '01'
IMPORTING
E_FIRST_DAY = fday
E_LAST_DAY = lday
EXCEPTIONS
INPUT_FALSE = 1
T009_NOTFOUND = 2
T009B_NOTFOUND = 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.
write:/ 'this is the first date of the year', fday .
write:/ 'this is the last date of the year', lday .
ABAP - How To Get All Month Names
REPORT zdates.
data: MONTH_NAMES like T247 occurs 0 with header line .
CALL FUNCTION 'MONTH_NAMES_GET'
EXPORTING
LANGUAGE = SY-LANGU
TABLES
month_names = month_names
EXCEPTIONS
MONTH_NAMES_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.
ENDIF.
loop at month_names.
write:/ month_names-LTX, month_names-mnr .
endloop.
data: MONTH_NAMES like T247 occurs 0 with header line .
CALL FUNCTION 'MONTH_NAMES_GET'
EXPORTING
LANGUAGE = SY-LANGU
TABLES
month_names = month_names
EXCEPTIONS
MONTH_NAMES_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.
ENDIF.
loop at month_names.
write:/ month_names-LTX, month_names-mnr .
endloop.
ABAP - Fetch First Day For Any Next Week - 'WEEK_GET_FIRST_DAY'
report zdates.
parameters:p_week type SCAL-WEEK.
initialization .
p_week = '200804'.
data:date type sy-datum .
start-of-selection .
CALL FUNCTION 'WEEK_GET_FIRST_DAY'
EXPORTING
week = p_week
IMPORTING
DATE = DATE
EXCEPTIONS
WEEK_INVALID = 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.
ENDIF.
write:/ 'the first date for the given week is :' , date .
parameters:p_week type SCAL-WEEK.
initialization .
p_week = '200804'.
data:date type sy-datum .
start-of-selection .
CALL FUNCTION 'WEEK_GET_FIRST_DAY'
EXPORTING
week = p_week
IMPORTING
DATE = DATE
EXCEPTIONS
WEEK_INVALID = 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.
ENDIF.
write:/ 'the first date for the given week is :' , date .
ABAP - How To Split The Pathname & Filename.
REPORT ZVENKATTEST.
parameters:p_file like rlgrap-filename .
data: PATHNAME type char50 ,
FILENAME type char50 .
at selection-screen on value-request for p_file .
CALL FUNCTION 'F4_FILENAME'
EXPORTING
PROGRAM_NAME = SYST-CPROG
DYNPRO_NUMBER = SYST-DYNNR
FIELD_NAME = 'P_FILE'
IMPORTING
FILE_NAME = p_file
.
start-of-selection .
CALL FUNCTION '/SAPDMC/LSM_PATH_FILE_SPLIT'
EXPORTING
PATHFILE = p_file
IMPORTING
PATHNAME = PATHNAME
FILENAME = FILENAME
.
write:/ 'PATHNAME IS : ' ,PATHNAME .
write:/ 'FILENAME IS : ' ,FILENAME .
parameters:p_file like rlgrap-filename .
data: PATHNAME type char50 ,
FILENAME type char50 .
at selection-screen on value-request for p_file .
CALL FUNCTION 'F4_FILENAME'
EXPORTING
PROGRAM_NAME = SYST-CPROG
DYNPRO_NUMBER = SYST-DYNNR
FIELD_NAME = 'P_FILE'
IMPORTING
FILE_NAME = p_file
.
start-of-selection .
CALL FUNCTION '/SAPDMC/LSM_PATH_FILE_SPLIT'
EXPORTING
PATHFILE = p_file
IMPORTING
PATHNAME = PATHNAME
FILENAME = FILENAME
.
write:/ 'PATHNAME IS : ' ,PATHNAME .
write:/ 'FILENAME IS : ' ,FILENAME .
ABAP - How To Copy A File On The PC - 'SCMS_FILE_COPY'
REPORT ZVENKATTEST.
PARAMETERS:P_SOUR LIKE RLGRAP-FILENAME , " This is the source file name
P_TARG LIKE RLGRAP-FILENAME . " This is the target file name
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_SOUR .
CALL FUNCTION 'F4_FILENAME'
EXPORTING
PROGRAM_NAME = SYST-CPROG
DYNPRO_NUMBER = SYST-DYNNR
FIELD_NAME = 'P_SOUR'
IMPORTING
FILE_NAME = P_SOUR.
START-OF-SELECTION .
CALL FUNCTION 'SCMS_FILE_COPY'
EXPORTING
SRC_FILENAME = p_sour
SRC_FRONTEND = 'X'
DST_FILENAME = p_TARG
DST_FRONTEND = 'X'
EXCEPTIONS
READ_FAILED = 1
WRITE_FAILED = 2
OTHERS = 3
.
IF SY-SUBRC eq 0.
write:/ ' the source file name was:', p_sour .
write:/ ' the copied file name was:' , p_targ .
ENDIF.
PARAMETERS:P_SOUR LIKE RLGRAP-FILENAME , " This is the source file name
P_TARG LIKE RLGRAP-FILENAME . " This is the target file name
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_SOUR .
CALL FUNCTION 'F4_FILENAME'
EXPORTING
PROGRAM_NAME = SYST-CPROG
DYNPRO_NUMBER = SYST-DYNNR
FIELD_NAME = 'P_SOUR'
IMPORTING
FILE_NAME = P_SOUR.
START-OF-SELECTION .
CALL FUNCTION 'SCMS_FILE_COPY'
EXPORTING
SRC_FILENAME = p_sour
SRC_FRONTEND = 'X'
DST_FILENAME = p_TARG
DST_FRONTEND = 'X'
EXCEPTIONS
READ_FAILED = 1
WRITE_FAILED = 2
OTHERS = 3
.
IF SY-SUBRC eq 0.
write:/ ' the source file name was:', p_sour .
write:/ ' the copied file name was:' , p_targ .
ENDIF.
ABAP - Check Whether A File Is Existing On PC.
REPORT ZVENKATTEST.
data: file_exists TYPE XFLAG .
parameters:p_file like rlgrap-filename .
at selection-screen on value-request for p_file .
CALL FUNCTION 'F4_FILENAME'
EXPORTING
PROGRAM_NAME = SYST-CPROG
DYNPRO_NUMBER = SYST-DYNNR
FIELD_NAME = 'P_FILE'
IMPORTING
FILE_NAME = p_file
.
start-of-selection .
CALL FUNCTION 'DX_FILE_EXISTENCE_CHECK'
EXPORTING
FILENAME = p_file
PC = 'X'
IMPORTING
FILE_EXISTS = FILE_EXISTS
EXCEPTIONS
RFC_ERROR = 1
FRONTEND_ERROR = 2
NO_AUTHORITY = 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.
if FILE_EXISTS = 'X'.
write:/ 'FILE EXISTS' .
else .
write:/ 'FILE doesnt EXISTS' .
endif.
data: file_exists TYPE XFLAG .
parameters:p_file like rlgrap-filename .
at selection-screen on value-request for p_file .
CALL FUNCTION 'F4_FILENAME'
EXPORTING
PROGRAM_NAME = SYST-CPROG
DYNPRO_NUMBER = SYST-DYNNR
FIELD_NAME = 'P_FILE'
IMPORTING
FILE_NAME = p_file
.
start-of-selection .
CALL FUNCTION 'DX_FILE_EXISTENCE_CHECK'
EXPORTING
FILENAME = p_file
PC = 'X'
IMPORTING
FILE_EXISTS = FILE_EXISTS
EXCEPTIONS
RFC_ERROR = 1
FRONTEND_ERROR = 2
NO_AUTHORITY = 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.
if FILE_EXISTS = 'X'.
write:/ 'FILE EXISTS' .
else .
write:/ 'FILE doesnt EXISTS' .
endif.
ABAP - Removing A File From Presentation Server Using FM GUI_DELETE_FILE.
REPORT ZVENKATTEST.
parameters: p_file type rlgrap-filename .
at selection-screen on value-request for p_file .
CALL FUNCTION 'F4_FILENAME'
EXPORTING
PROGRAM_NAME = SYST-CPROG
DYNPRO_NUMBER = SYST-DYNNR
FIELD_NAME = 'P_FILE'
IMPORTING
FILE_NAME = p_file
.
start-of-selection .
CALL FUNCTION 'GUI_DELETE_FILE'
EXPORTING
FILE_NAME = p_file
EXCEPTIONS
FAILED = 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.
ENDIF.
write:/ 'the file' , p_file , 'removed successfully '.
RETURN TO MAIN INDEX:
- Sample Programs On Uploading & Downloading Files.
- Sample Programs On HR ABAP.
- Sample Report Programs On ALV List/ Grid Display.
- Sample Programs On Selection Screen.
- Sample Programs On BDC.
.....Back To MAIN INDEX.
parameters: p_file type rlgrap-filename .
at selection-screen on value-request for p_file .
CALL FUNCTION 'F4_FILENAME'
EXPORTING
PROGRAM_NAME = SYST-CPROG
DYNPRO_NUMBER = SYST-DYNNR
FIELD_NAME = 'P_FILE'
IMPORTING
FILE_NAME = p_file
.
start-of-selection .
CALL FUNCTION 'GUI_DELETE_FILE'
EXPORTING
FILE_NAME = p_file
EXCEPTIONS
FAILED = 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.
ENDIF.
write:/ 'the file' , p_file , 'removed successfully '.
RETURN TO MAIN INDEX:
- Sample Programs On Uploading & Downloading Files.
- Sample Programs On HR ABAP.
- Sample Report Programs On ALV List/ Grid Display.
- Sample Programs On Selection Screen.
- Sample Programs On BDC.
.....Back To MAIN INDEX.
ABAP - Removing A Directory From Presentation Server Using FM GUI_REMOVE_DIRECTORY.
REPORT ZVENKATTEST.
parameters: p_dir type rlgrap-filename .
at selection-screen on value-request for p_dir .
CALL FUNCTION 'F4_FILENAME'
EXPORTING
PROGRAM_NAME = SYST-CPROG
DYNPRO_NUMBER = SYST-DYNNR
FIELD_NAME = 'P_DIR'
IMPORTING
FILE_NAME = p_dir
.
start-of-selection .
CALL FUNCTION 'GUI_REMOVE_DIRECTORY'
EXPORTING
DIRNAME = p_dir
EXCEPTIONS
FAILED = 1
OTHERS = 2
.
write:/ 'the directory' , p_dir , 'removed successfully '.
RETURN TO MAIN INDEX:
- Sample Programs On Uploading & Downloading Files.
- Sample Programs On HR ABAP.
- Sample Report Programs On ALV List/ Grid Display.
- Sample Programs On Selection Screen.
- Sample Programs On BDC.
.....Back To MAIN INDEX.
parameters: p_dir type rlgrap-filename .
at selection-screen on value-request for p_dir .
CALL FUNCTION 'F4_FILENAME'
EXPORTING
PROGRAM_NAME = SYST-CPROG
DYNPRO_NUMBER = SYST-DYNNR
FIELD_NAME = 'P_DIR'
IMPORTING
FILE_NAME = p_dir
.
start-of-selection .
CALL FUNCTION 'GUI_REMOVE_DIRECTORY'
EXPORTING
DIRNAME = p_dir
EXCEPTIONS
FAILED = 1
OTHERS = 2
.
write:/ 'the directory' , p_dir , 'removed successfully '.
RETURN TO MAIN INDEX:
- Sample Programs On Uploading & Downloading Files.
- Sample Programs On HR ABAP.
- Sample Report Programs On ALV List/ Grid Display.
- Sample Programs On Selection Screen.
- Sample Programs On BDC.
.....Back To MAIN INDEX.
ABAP - Creating A Directory On Presentation Server Using FM GUI_CREATE_DIRECTORY.
REPORT ZVENKATTEST.
parameters: p_dir type rlgrap-filename .
at selection-screen on value-request for p_dir .
CALL FUNCTION 'F4_FILENAME'
EXPORTING
PROGRAM_NAME = SYST-CPROG
DYNPRO_NUMBER = SYST-DYNNR
FIELD_NAME = 'P_DIR'
IMPORTING
FILE_NAME = p_dir
.
start-of-selection .
CALL FUNCTION 'GUI_CREATE_DIRECTORY'
EXPORTING
DIRNAME = p_dir
EXCEPTIONS
FAILED = 1
OTHERS = 2
.
write:/ 'the directory' , p_dir , 'created successfully '.
ALSO READ:
- Removing A Directory From Presentation Server Using FM GUI_REMOVE_DIRECTORY.
- Removing A File From Presentation Server Using FM GUI_DELETE_FILE.
- ZIP Files In Application Server Using FM SCMS_XSTRING_TO_BINARY.
- Saving Files To Presentation Server Using Methods.
- Uploading CSV Files Into Internal Table Using FM GUI_UPLOAD.
RETURN TO MAIN INDEX:
- Sample Programs On Uploading & Downloading Files.
- Sample Programs On HR ABAP.
- Sample Report Programs On ALV List/ Grid Display.
- Sample Programs On Selection Screen.
- Sample Programs On BDC.
.....Back To MAIN INDEX.
parameters: p_dir type rlgrap-filename .
at selection-screen on value-request for p_dir .
CALL FUNCTION 'F4_FILENAME'
EXPORTING
PROGRAM_NAME = SYST-CPROG
DYNPRO_NUMBER = SYST-DYNNR
FIELD_NAME = 'P_DIR'
IMPORTING
FILE_NAME = p_dir
.
start-of-selection .
CALL FUNCTION 'GUI_CREATE_DIRECTORY'
EXPORTING
DIRNAME = p_dir
EXCEPTIONS
FAILED = 1
OTHERS = 2
.
write:/ 'the directory' , p_dir , 'created successfully '.
ALSO READ:
- Removing A Directory From Presentation Server Using FM GUI_REMOVE_DIRECTORY.
- Removing A File From Presentation Server Using FM GUI_DELETE_FILE.
- ZIP Files In Application Server Using FM SCMS_XSTRING_TO_BINARY.
- Saving Files To Presentation Server Using Methods.
- Uploading CSV Files Into Internal Table Using FM GUI_UPLOAD.
RETURN TO MAIN INDEX:
- Sample Programs On Uploading & Downloading Files.
- Sample Programs On HR ABAP.
- Sample Report Programs On ALV List/ Grid Display.
- Sample Programs On Selection Screen.
- Sample Programs On BDC.
.....Back To MAIN INDEX.
ABAP - Deleteing A Table In Archiving.
REPORT YARCHTEST_DEL MESSAGE-ID YAPK
NO STANDARD PAGE HEADING
LINE-SIZE 255.
* Internal Table Declarations.......................................
DATA: BEGIN OF I_YAPTMAIN OCCURS 0.
INCLUDE STRUCTURE YAPTMAIN .
DATA: END OF I_YAPTMAIN.
DATA: BEGIN OF I_SEL_FILES_ITAB OCCURS 0.
INCLUDE STRUCTURE ARCH_FILES.
DATA: END OF I_SEL_FILES_ITAB.
DATA: I_INDEX_TAB TYPE TABLE OF ARCH_IDX_S WITH HEADER LINE,
I_STAT_ITAB TYPE TABLE OF ARCH_STAT.
*- Structure........................................................
DATA: BEGIN OF K_BUFFER.
INCLUDE STRUCTURE arc_buffer.
DATA: END OF K_BUFFER.
DATA: K_TABLE_WA LIKE YAPTMAIN.
*Work Variables.....................................................
DATA: V_COMMIT_CNT LIKE ARCH_USR-ARCH_COMIT,
V_INDEX_FLAG LIKE ARCH_USR-ARCH_INDEX,
V_OBJECT_ID LIKE ARCH_IDX_S-OBJ_ID,
V_OFFSET LIKE ARCH_IDX_S-OBJ_OFFSET,
V_ARKEY LIKE ARCH_IDX_S-ARCHIVEKEY,
V_OBJECT_CNT TYPE I,
V_SUM_OBJECTS TYPE I VALUE 0,
V_SUM_OBJECTS1 TYPE I VALUE 0,
V_HANDLE LIKE SY-TABIX,
K_TABFIELD LIKE ARCH_STAT.
*Constants..........................................................
CONSTANTS: C_SPACE VALUE SPACE,
C_X VALUE 'X',
C_OBJECT(10) VALUE 'YARCHTEST',
C_TABLE(30) VALUE 'YAPTMAIN',
C_TEXT7(15) VALUE 'Test Run',
C_0 VALUE 0,
C_MSG1(70) VALUE 'No file can be accessed',
C_MSG2(70) VALUE 'Unable to access customizing data',
C_MSG3(70) VALUE 'Unable to provide statistics',
C_MSG4(70) VALUE 'Unable to Write statistics',
C_MSG5(70) VALUE 'Unable to process files for update',
C_MSG6(70) VALUE 'Unable to close archive session'.
*- Selection Screen...............................................
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE V_TEXT1.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT (29) V_TEST.
PARAMETERS: TESTRUN DEFAULT'X' AS CHECKBOX.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK B1.
INITIALIZATION.
SY-TITLE = ' Delete Records for Object - YARCHTEST'.
V_TEXT1 = 'Selection Details'.
V_TEST = C_TEXT7.
START-OF-SELECTION.
PERFORM OPEN_ARCHIVE_FOR_DELETE.
PERFORM GET_ARCHIVE_CUST_DATA.
PERFORM DELETE_DATA.
PERFORM WRITE_STATISTICS.
PERFORM GET_ARCHIVE_FILES.
PERFORM CLOSE_ARCHIVE_FILE.
END-OF-SELECTION.
*& ---------------------------------------------------------*
*& Form OPEN_ARCHIVE_FOR_DELETE
*& -------------------------------------------------- *
* Open Archive File for Deleting Data
*& ---------------------------------------------------------*
FORM OPEN_ARCHIVE_FOR_DELETE.
CALL FUNCTION 'ARCHIVE_OPEN_FOR_DELETE'
EXPORTING
object = c_object
TEST_MODE = TESTRUN
IMPORTING
archive_handle = V_HANDLE
EXCEPTIONS
file_already_open = 1
FILE_IO_ERROR = 2
INTERNAL_ERROR = 3
NO_FILES_AVAILABLE = 4
OBJECT_NOT_FOUND = 5
OPEN_ERROR = 6
NOT_AUTHORIZED = 7
OTHERS = 8.
IF SY-SUBRC > C_0.
MESSAGE I001 WITH C_MSG1.
EXIT.
ENDIF.
ENDFORM.
*& ---------------------------------------------------------*
*& Form GET_ARCHIVE_CUST_DATA
*&----------------------------------------------------------*
* Get Customizing data for the Archive File
*& ---------------------------------------------------------*
FORM GET_ARCHIVE_CUST_DATA.
CALL FUNCTION 'ARCHIVE_GET_CUSTOMIZING_DATA'
EXPORTING
object = c_object
IMPORTING
COMMIT_COUNT_FOR_DELETE_PRG = V_COMMIT_CNT
EXCEPTIONS
OBJECT_NOT_FOUND = 1
OTHERS = 2.
IF SY-SUBRC > C_0.
MESSAGE I001 WITH C_MSG2.
EXIT.
ENDIF.
ENDFORM.
*& ---------------------------------------------------------*
*& Form DELETE_DATA
*&----------------------------------------------------------*
* Delete Archive Data
*& ---------------------------------------------------------*
FORM DELETE_DATA.
CLEAR: V_OBJECT_CNT.
CLEAR: V_SUM_OBJECTS,V_SUM_OBJECTS1.
DO.
ADD 1 TO V_OBJECT_CNT.
CALL FUNCTION 'ARCHIVE_GET_NEXT_OBJECT'
EXPORTING
ARCHIVE_HANDLE = V_HANDLE
IMPORTING
OBJECT_ID = V_OBJECT_ID
OBJECT_OFFSET = V_OFFSET
ARCHIVE_NAME = V_ARKEY
EXCEPTIONS
END_OF_FILE = 1
FILE_IO_ERROR = 2
INTERNAL_ERROR = 3
OPEN_ERROR = 4
WRONG_ACCESS_TO_ARCHIVE = 5
OTHERS = 6.
IF SY-SUBRC <> C_0.
EXIT.
ENDIF.
IF V_INDEX_FLAG IS INITIAL.
ELSEIF TESTRUN IS INITIAL.
MOVE: V_OBJECT_ID TO I_INDEX_TAB-OBJ_ID,
V_ARKEY TO I_INDEX_TAB-ARCHIVEKEY,
V_OFFSET TO I_INDEX_TAB-OBJ_OFFSET.
APPEND I_INDEX_TAB.
PERFORM SAVE_INDEX_TAB ON COMMIT.
ENDIF.
DO.
CALL FUNCTION 'ARCHIVE_GET_NEXT_RECORD'
EXPORTING
ARCHIVE_HANDLE = V_HANDLE
IMPORTING
RECORD = K_BUFFER-SEGMENT
RECORD_STRUCTURE = K_BUFFER-RNAME
EXCEPTIONS
END_OF_OBJECT = 1
INTERNAL_ERROR = 2
WRONG_ACCESS_TO_ARCHIVE = 3
OTHERS = 4.
IF SY-SUBRC <> C_0.
EXIT.
ENDIF.
CASE K_BUFFER-rname.
WHEN C_TABLE.
MOVE K_BUFFER-SEGMENT TO K_TABLE_WA.
APPEND K_TABLE_WA TO I_YAPTMAIN.
ENDCASE.
ENDDO.
IF TESTRUN IS INITIAL AND V_OBJECT_CNT = V_COMMIT_CNT.
DESCRIBE TABLE I_YAPTMAIN
LINES V_SUM_OBJECTS.
PERFORM DELETE_FROM_TABLE.
V_SUM_OBJECTS1 = V_SUM_OBJECTS1 + V_SUM_OBJECTS.
CLEAR: V_SUM_OBJECTS.
CLEAR I_YAPTMAIN.
REFRESH I_YAPTMAIN.
CLEAR V_OBJECT_CNT.
ENDIF.
ENDDO.
IF TESTRUN IS INITIAL AND V_OBJECT_CNT > 1.
PERFORM DELETE_FROM_TABLE.
ENDIF.
DESCRIBE TABLE I_YAPTMAIN
LINES V_SUM_OBJECTS.
REFRESH I_YAPTMAIN.
K_TABFIELD-TABNAME = C_SPACE.
V_SUM_OBJECTS1 = V_SUM_OBJECTS1 + V_SUM_OBJECTS.
K_TABFIELD-COUNT = V_SUM_OBJECTS1.
APPEND K_TABFIELD TO I_STAT_ITAB.
K_TABFIELD-TABNAME = C_TABLE.
K_TABFIELD-COUNT = V_SUM_OBJECTS1.
APPEND K_TABFIELD TO I_STAT_ITAB.
*& ---------------------------------------------------------*
CALL FUNCTION 'ARCHIVE_GIVE_STATISTICS'
EXPORTING
ARCHIVE_HANDLE = V_HANDLE
TABLES
TABLE = I_STAT_ITAB
EXCEPTIONS
INTERNAL_ERROR = 1
OTHERS = 2.
IF SY-SUBRC <> C_0.
MESSAGE I001 WITH C_MSG3.
EXIT.
ENDIF.
ENDFORM.
*& ---------------------------------------------------------*
*& Form WRITE_STATISTICS
*&----------------------------------------------------------*
* Write Statistics
*& ---------------------------------------------------------*
FORM WRITE_STATISTICS.
CALL FUNCTION 'ARCHIVE_WRITE_STATISTICS'
EXPORTING
ARCHIVE_HANDLE = V_HANDLE
EXCEPTIONS
INTERNAL_ERROR = 1
OTHERS = 2.
IF SY-SUBRC <> C_0.
MESSAGE I001 WITH C_MSG4.
EXIT.
ENDIF.
ENDFORM.
*& ---------------------------------------------------------*
*& Form GET_ARCHIVE_FILES
*&----------------------------------------------------------*
* Get all processed files for update
*& ---------------------------------------------------------*
FORM GET_ARCHIVE_FILES.
CALL FUNCTION 'ARCHIVE_GET_ARCHIVE_FILES'
EXPORTING
ARCHIVE_HANDLE = V_HANDLE
TABLES
ARCHIVE_FILES = I_SEL_FILES_ITAB
EXCEPTIONS
WRONG_ACCESS_TO_ARCHIVE = 1
INTERNAL_ERROR = 2
OTHERS = 3.
IF SY-SUBRC <> C_0.
MESSAGE I001 WITH C_MSG5.
EXIT.
ENDIF.
ENDFORM.
*& ---------------------------------------------------------*
*& Form CLOSE_ARCHIVE_FILE
*&----------------------------------------------------------*
* Close Archive File
*& ---------------------------------------------------------*
FORM CLOSE_ARCHIVE_FILE.
CALL FUNCTION 'ARCHIVE_CLOSE_FILE'
EXPORTING
ARCHIVE_HANDLE = V_HANDLE
EXCEPTIONS
INTERNAL_ERROR = 1
WRONG_ACCESS_TO_ARCHIVE = 2
OTHERS = 3.
IF SY-SUBRC <> C_0.
MESSAGE I001 WITH C_MSG6.
EXIT.
ENDIF.
IF V_INDEX_FLAG IS INITIAL.
ELSEIF TESTRUN IS INITIAL.
CALL FUNCTION 'ARCHIVE_ADMIN_SET_STATUS'
EXPORTING
FILES_ARE_CONVERTED = C_SPACE
INDEX_CREATED = C_X
TABLES
ARCHIVE_FILES = I_SEL_FILES_ITAB
EXCEPTIONS
CANNOT_CHANGE_STATUS = 1
OTHERS = 2.
ENDIF.
ENDFORM.
*& ---------------------------------------------------------*
*& Form save_index_tab
*&----------------------------------------------------------*
FORM SAVE_INDEX_TAB.
DELETE ARCH_IDX_S FROM TABLE I_INDEX_TAB.
INSERT ARCH_IDX_S FROM TABLE I_INDEX_TAB.
REFRESH I_INDEX_TAB.
ENDFORM.
*& ---------------------------------------------------------*
*& Form DELETE_FROM_TABLE
*&----------------------------------------------------------*
* DELETE_FROM_TABLE
*& ---------------------------------------------------------*
FORM DELETE_FROM_TABLE.
DELETE YAPTMAIN FROM TABLE I_YAPTMAIN.
COMMIT WORK.
ENDFORM.
NO STANDARD PAGE HEADING
LINE-SIZE 255.
* Internal Table Declarations.......................................
DATA: BEGIN OF I_YAPTMAIN OCCURS 0.
INCLUDE STRUCTURE YAPTMAIN .
DATA: END OF I_YAPTMAIN.
DATA: BEGIN OF I_SEL_FILES_ITAB OCCURS 0.
INCLUDE STRUCTURE ARCH_FILES.
DATA: END OF I_SEL_FILES_ITAB.
DATA: I_INDEX_TAB TYPE TABLE OF ARCH_IDX_S WITH HEADER LINE,
I_STAT_ITAB TYPE TABLE OF ARCH_STAT.
*- Structure........................................................
DATA: BEGIN OF K_BUFFER.
INCLUDE STRUCTURE arc_buffer.
DATA: END OF K_BUFFER.
DATA: K_TABLE_WA LIKE YAPTMAIN.
*Work Variables.....................................................
DATA: V_COMMIT_CNT LIKE ARCH_USR-ARCH_COMIT,
V_INDEX_FLAG LIKE ARCH_USR-ARCH_INDEX,
V_OBJECT_ID LIKE ARCH_IDX_S-OBJ_ID,
V_OFFSET LIKE ARCH_IDX_S-OBJ_OFFSET,
V_ARKEY LIKE ARCH_IDX_S-ARCHIVEKEY,
V_OBJECT_CNT TYPE I,
V_SUM_OBJECTS TYPE I VALUE 0,
V_SUM_OBJECTS1 TYPE I VALUE 0,
V_HANDLE LIKE SY-TABIX,
K_TABFIELD LIKE ARCH_STAT.
*Constants..........................................................
CONSTANTS: C_SPACE VALUE SPACE,
C_X VALUE 'X',
C_OBJECT(10) VALUE 'YARCHTEST',
C_TABLE(30) VALUE 'YAPTMAIN',
C_TEXT7(15) VALUE 'Test Run',
C_0 VALUE 0,
C_MSG1(70) VALUE 'No file can be accessed',
C_MSG2(70) VALUE 'Unable to access customizing data',
C_MSG3(70) VALUE 'Unable to provide statistics',
C_MSG4(70) VALUE 'Unable to Write statistics',
C_MSG5(70) VALUE 'Unable to process files for update',
C_MSG6(70) VALUE 'Unable to close archive session'.
*- Selection Screen...............................................
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE V_TEXT1.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT (29) V_TEST.
PARAMETERS: TESTRUN DEFAULT'X' AS CHECKBOX.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK B1.
INITIALIZATION.
SY-TITLE = ' Delete Records for Object - YARCHTEST'.
V_TEXT1 = 'Selection Details'.
V_TEST = C_TEXT7.
START-OF-SELECTION.
PERFORM OPEN_ARCHIVE_FOR_DELETE.
PERFORM GET_ARCHIVE_CUST_DATA.
PERFORM DELETE_DATA.
PERFORM WRITE_STATISTICS.
PERFORM GET_ARCHIVE_FILES.
PERFORM CLOSE_ARCHIVE_FILE.
END-OF-SELECTION.
*& ---------------------------------------------------------*
*& Form OPEN_ARCHIVE_FOR_DELETE
*& -------------------------------------------------- *
* Open Archive File for Deleting Data
*& ---------------------------------------------------------*
FORM OPEN_ARCHIVE_FOR_DELETE.
CALL FUNCTION 'ARCHIVE_OPEN_FOR_DELETE'
EXPORTING
object = c_object
TEST_MODE = TESTRUN
IMPORTING
archive_handle = V_HANDLE
EXCEPTIONS
file_already_open = 1
FILE_IO_ERROR = 2
INTERNAL_ERROR = 3
NO_FILES_AVAILABLE = 4
OBJECT_NOT_FOUND = 5
OPEN_ERROR = 6
NOT_AUTHORIZED = 7
OTHERS = 8.
IF SY-SUBRC > C_0.
MESSAGE I001 WITH C_MSG1.
EXIT.
ENDIF.
ENDFORM.
*& ---------------------------------------------------------*
*& Form GET_ARCHIVE_CUST_DATA
*&----------------------------------------------------------*
* Get Customizing data for the Archive File
*& ---------------------------------------------------------*
FORM GET_ARCHIVE_CUST_DATA.
CALL FUNCTION 'ARCHIVE_GET_CUSTOMIZING_DATA'
EXPORTING
object = c_object
IMPORTING
COMMIT_COUNT_FOR_DELETE_PRG = V_COMMIT_CNT
EXCEPTIONS
OBJECT_NOT_FOUND = 1
OTHERS = 2.
IF SY-SUBRC > C_0.
MESSAGE I001 WITH C_MSG2.
EXIT.
ENDIF.
ENDFORM.
*& ---------------------------------------------------------*
*& Form DELETE_DATA
*&----------------------------------------------------------*
* Delete Archive Data
*& ---------------------------------------------------------*
FORM DELETE_DATA.
CLEAR: V_OBJECT_CNT.
CLEAR: V_SUM_OBJECTS,V_SUM_OBJECTS1.
DO.
ADD 1 TO V_OBJECT_CNT.
CALL FUNCTION 'ARCHIVE_GET_NEXT_OBJECT'
EXPORTING
ARCHIVE_HANDLE = V_HANDLE
IMPORTING
OBJECT_ID = V_OBJECT_ID
OBJECT_OFFSET = V_OFFSET
ARCHIVE_NAME = V_ARKEY
EXCEPTIONS
END_OF_FILE = 1
FILE_IO_ERROR = 2
INTERNAL_ERROR = 3
OPEN_ERROR = 4
WRONG_ACCESS_TO_ARCHIVE = 5
OTHERS = 6.
IF SY-SUBRC <> C_0.
EXIT.
ENDIF.
IF V_INDEX_FLAG IS INITIAL.
ELSEIF TESTRUN IS INITIAL.
MOVE: V_OBJECT_ID TO I_INDEX_TAB-OBJ_ID,
V_ARKEY TO I_INDEX_TAB-ARCHIVEKEY,
V_OFFSET TO I_INDEX_TAB-OBJ_OFFSET.
APPEND I_INDEX_TAB.
PERFORM SAVE_INDEX_TAB ON COMMIT.
ENDIF.
DO.
CALL FUNCTION 'ARCHIVE_GET_NEXT_RECORD'
EXPORTING
ARCHIVE_HANDLE = V_HANDLE
IMPORTING
RECORD = K_BUFFER-SEGMENT
RECORD_STRUCTURE = K_BUFFER-RNAME
EXCEPTIONS
END_OF_OBJECT = 1
INTERNAL_ERROR = 2
WRONG_ACCESS_TO_ARCHIVE = 3
OTHERS = 4.
IF SY-SUBRC <> C_0.
EXIT.
ENDIF.
CASE K_BUFFER-rname.
WHEN C_TABLE.
MOVE K_BUFFER-SEGMENT TO K_TABLE_WA.
APPEND K_TABLE_WA TO I_YAPTMAIN.
ENDCASE.
ENDDO.
IF TESTRUN IS INITIAL AND V_OBJECT_CNT = V_COMMIT_CNT.
DESCRIBE TABLE I_YAPTMAIN
LINES V_SUM_OBJECTS.
PERFORM DELETE_FROM_TABLE.
V_SUM_OBJECTS1 = V_SUM_OBJECTS1 + V_SUM_OBJECTS.
CLEAR: V_SUM_OBJECTS.
CLEAR I_YAPTMAIN.
REFRESH I_YAPTMAIN.
CLEAR V_OBJECT_CNT.
ENDIF.
ENDDO.
IF TESTRUN IS INITIAL AND V_OBJECT_CNT > 1.
PERFORM DELETE_FROM_TABLE.
ENDIF.
DESCRIBE TABLE I_YAPTMAIN
LINES V_SUM_OBJECTS.
REFRESH I_YAPTMAIN.
K_TABFIELD-TABNAME = C_SPACE.
V_SUM_OBJECTS1 = V_SUM_OBJECTS1 + V_SUM_OBJECTS.
K_TABFIELD-COUNT = V_SUM_OBJECTS1.
APPEND K_TABFIELD TO I_STAT_ITAB.
K_TABFIELD-TABNAME = C_TABLE.
K_TABFIELD-COUNT = V_SUM_OBJECTS1.
APPEND K_TABFIELD TO I_STAT_ITAB.
*& ---------------------------------------------------------*
CALL FUNCTION 'ARCHIVE_GIVE_STATISTICS'
EXPORTING
ARCHIVE_HANDLE = V_HANDLE
TABLES
TABLE = I_STAT_ITAB
EXCEPTIONS
INTERNAL_ERROR = 1
OTHERS = 2.
IF SY-SUBRC <> C_0.
MESSAGE I001 WITH C_MSG3.
EXIT.
ENDIF.
ENDFORM.
*& ---------------------------------------------------------*
*& Form WRITE_STATISTICS
*&----------------------------------------------------------*
* Write Statistics
*& ---------------------------------------------------------*
FORM WRITE_STATISTICS.
CALL FUNCTION 'ARCHIVE_WRITE_STATISTICS'
EXPORTING
ARCHIVE_HANDLE = V_HANDLE
EXCEPTIONS
INTERNAL_ERROR = 1
OTHERS = 2.
IF SY-SUBRC <> C_0.
MESSAGE I001 WITH C_MSG4.
EXIT.
ENDIF.
ENDFORM.
*& ---------------------------------------------------------*
*& Form GET_ARCHIVE_FILES
*&----------------------------------------------------------*
* Get all processed files for update
*& ---------------------------------------------------------*
FORM GET_ARCHIVE_FILES.
CALL FUNCTION 'ARCHIVE_GET_ARCHIVE_FILES'
EXPORTING
ARCHIVE_HANDLE = V_HANDLE
TABLES
ARCHIVE_FILES = I_SEL_FILES_ITAB
EXCEPTIONS
WRONG_ACCESS_TO_ARCHIVE = 1
INTERNAL_ERROR = 2
OTHERS = 3.
IF SY-SUBRC <> C_0.
MESSAGE I001 WITH C_MSG5.
EXIT.
ENDIF.
ENDFORM.
*& ---------------------------------------------------------*
*& Form CLOSE_ARCHIVE_FILE
*&----------------------------------------------------------*
* Close Archive File
*& ---------------------------------------------------------*
FORM CLOSE_ARCHIVE_FILE.
CALL FUNCTION 'ARCHIVE_CLOSE_FILE'
EXPORTING
ARCHIVE_HANDLE = V_HANDLE
EXCEPTIONS
INTERNAL_ERROR = 1
WRONG_ACCESS_TO_ARCHIVE = 2
OTHERS = 3.
IF SY-SUBRC <> C_0.
MESSAGE I001 WITH C_MSG6.
EXIT.
ENDIF.
IF V_INDEX_FLAG IS INITIAL.
ELSEIF TESTRUN IS INITIAL.
CALL FUNCTION 'ARCHIVE_ADMIN_SET_STATUS'
EXPORTING
FILES_ARE_CONVERTED = C_SPACE
INDEX_CREATED = C_X
TABLES
ARCHIVE_FILES = I_SEL_FILES_ITAB
EXCEPTIONS
CANNOT_CHANGE_STATUS = 1
OTHERS = 2.
ENDIF.
ENDFORM.
*& ---------------------------------------------------------*
*& Form save_index_tab
*&----------------------------------------------------------*
FORM SAVE_INDEX_TAB.
DELETE ARCH_IDX_S FROM TABLE I_INDEX_TAB.
INSERT ARCH_IDX_S FROM TABLE I_INDEX_TAB.
REFRESH I_INDEX_TAB.
ENDFORM.
*& ---------------------------------------------------------*
*& Form DELETE_FROM_TABLE
*&----------------------------------------------------------*
* DELETE_FROM_TABLE
*& ---------------------------------------------------------*
FORM DELETE_FROM_TABLE.
DELETE YAPTMAIN FROM TABLE I_YAPTMAIN.
COMMIT WORK.
ENDFORM.
ABAP - Reloading A Table (Archiving)
REPORT YARCHTEST_REL MESSAGE-ID YAPK
NO STANDARD PAGE HEADING
LINE-SIZE 255.
*- Tables Declarations.
TABLES: YAPTMAIN.
TYPE-POOLS SLIS.
*- Internal Table Declarations....................................
DATA: BEGIN OF I_YAPTMAIN OCCURS 0.
INCLUDE STRUCTURE YAPTMAIN .
DATA: END OF I_YAPTMAIN.
DATA: I_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV.
DATA: I_EVENTS TYPE SLIS_T_EVENT.
DATA: I_INDEX_TAB TYPE TABLE OF ARCH_IDX_S WITH HEADER LINE.
DATA: I_SEL_FILES_ITAB TYPE TABLE OF ARCH_FILES.
*- Structures.......................................................
DATA: BEGIN OF K_BUFFER.
INCLUDE STRUCTURE arc_buffer.
DATA: END OF K_BUFFER,
K_TABLE_WA LIKE YAPTMAIN.
*- Structure for Layout.
DATA: X_LAYOUT TYPE SLIS_LAYOUT_ALV.
DATA:V_READ_HANDLE LIKE sy-tabix,
v_exi TYPE c,
v_x TYPE c VALUE 'X',
v_returncode TYPE c,
V_COMMIT_CNT LIKE ARCH_USR-ARCH_COMIT,
V_OBJECT_CNT TYPE I,
V_READ_CNT TYPE I,
V_RELOAD_CNT TYPE I,
V_ARKEY LIKE ARCH_IDX_S-ARCHIVEKEY,
V_OBJECT_ID LIKE ARCH_IDX_S-OBJ_ID,
V_OFFSET LIKE ARCH_IDX_S-OBJ_OFFSET,
V_DUPREC TYPE C,
V_I_TAB TYPE SLIS_TABNAME.
*--Constants........................................................
CONSTANTS: C_0 VALUE 0,
C_SPACE VALUE SPACE,
C_1 VALUE 1,
C_4 VALUE 4,
C_X VALUE 'X',
C_TOP_OF_LIST(15) VALUE 'TOP_OF_LIST',
C_TOP_OF_LIST_YAPTMAIN(35) VALUE 'TOP_OF_LIST_YAPTMAIN',
C_I_YAPTMAIN(35) VALUE 'I_YAPTMAIN',
C_MSG1(25) VALUE 'No file can be accessed',
C_MSG2(40) VALUE 'Unable to access customizing data',
C_MSG3(25) VALUE 'Unable to Process Files',
C_TEXT1(25) VALUE 'There were duplicate keys',
C_TEXT2(25) VALUE 'RELOADED ARCHIVE INFO:',
C_TEXT3(25) VALUE 'Data Objects Read',
C_TEXT4(25) VALUE 'Data Objects Reloaded',
C_TEXT5(50) VALUE ' Reloaded Records for Object - YARCHTEST ' ,
C_TEXT6(50) VALUE ' YAPTMAIN - Archive Objects Information ' ,
C_TEXT7(15) VALUE 'Test Run',
C_TABLE(30) VALUE 'YAPTMAIN',
C_OBJECT(10) VALUE 'YARCHTEST'.
*- Selection Screen.
SELECTION-SCREEN BEGIN OF BLOCK B2 WITH FRAME TITLE V_TEXT2.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT (29) V_TEST.
PARAMETERS: TESTRUN DEFAULT'X' AS CHECKBOX.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK B2.
INITIALIZATION.
SY-TITLE = ' Reload Records for Object - YARCHTEST'.
V_TEXT2 = 'Test Run'.
CONCATENATE '''' C_I_YAPTMAIN '''' INTO V_I_TAB.
CONDENSE V_I_TAB NO-GAPS.
*- Get Selection Screen Texts.
PERFORM GET_SELECTION_TEXTS.
*- Popuate the layout structure for display.
PERFORM POPULATE_LAYOUT.
START-OF-SELECTION.
PERFORM OPEN_ARCHIVE_FILE.
PERFORM GET_CUSTOMIZING_DATA.
CLEAR: V_OBJECT_CNT, V_DUPREC, V_READ_CNT, V_RELOAD_CNT.
DO.
ADD 1 TO V_OBJECT_CNT.
CALL FUNCTION 'ARCHIVE_GET_NEXT_OBJECT'
EXPORTING
ARCHIVE_HANDLE = V_READ_HANDLE
IMPORTING
OBJECT_ID = V_OBJECT_ID
OBJECT_OFFSET = V_OFFSET
ARCHIVE_NAME = V_ARKEY
EXCEPTIONS
END_OF_FILE = 1
FILE_IO_ERROR = 2
INTERNAL_ERROR = 3
OPEN_ERROR = 4
WRONG_ACCESS_TO_ARCHIVE = 5
OTHERS = 6.
IF SY-SUBRC <> C_0.
EXIT.
ENDIF.
ADD 1 TO V_READ_CNT.
MOVE: V_OBJECT_ID TO I_INDEX_TAB-OBJ_ID,
V_ARKEY TO I_INDEX_TAB-ARCHIVEKEY,
V_OFFSET TO I_INDEX_TAB-OBJ_OFFSET.
APPEND I_INDEX_TAB.
PERFORM DELETE_INDEX_TAB ON COMMIT.
DO.
CALL FUNCTION 'ARCHIVE_GET_NEXT_RECORD'
EXPORTING
ARCHIVE_HANDLE = V_READ_HANDLE
IMPORTING
RECORD = K_BUFFER-SEGMENT
RECORD_STRUCTURE = K_BUFFER-RNAME
EXCEPTIONS
END_OF_OBJECT = 1
INTERNAL_ERROR = 2
WRONG_ACCESS_TO_ARCHIVE = 3
OTHERS = 4.
IF SY-SUBRC <> C_0.
EXIT.
ENDIF.
CASE K_BUFFER-rname.
WHEN C_TABLE.
MOVE K_BUFFER-SEGMENT TO K_TABLE_WA.
APPEND K_TABLE_WA TO I_YAPTMAIN.
ENDCASE.
ENDDO.
IF V_OBJECT_CNT = V_COMMIT_CNT.
PERFORM INSERT_FROM_TABLE.
CLEAR V_OBJECT_CNT.
ENDIF.
ENDDO.
IF V_OBJECT_CNT > C_1.
PERFORM INSERT_FROM_TABLE.
ENDIF.
PERFORM GET_ARCHIVE_FILE.
PERFORM CLOSE_ARCHIVE_FILE.
END-OF-SELECTION.
PERFORM WRITE_STATISTICS.
*- Output the data using ALV.
PERFORM OUTPUT_DATA_USING_ALV.
*& ---------------------------------------------------------*
*& Form ARCHIVE_OPEN_FOR_READ
*&----------------------------------------------------------*
* ARCHIVE_OPEN_FOR_READ
*& ---------------------------------------------------------*
FORM OPEN_ARCHIVE_FILE.
CALL FUNCTION 'ARCHIVE_OPEN_FOR_MOVE'
EXPORTING
object = C_OBJECT
TEST_MODE = TESTRUN
IMPORTING
archive_READ_handle = V_READ_HANDLE
EXCEPTIONS
file_already_open = 1
FILE_IO_ERROR = 2
INTERNAL_ERROR = 3
NO_FILES_AVAILABLE = 4
OBJECT_NOT_FOUND = 5
OPEN_ERROR = 6
NOT_AUTHORIZED = 7
OTHERS = 8.
IF SY-SUBRC > C_0.
MESSAGE I001 WITH C_MSG1.
EXIT.
ENDIF.
ENDFORM.
*& ---------------------------------------------------------*
*& Form GET_CUSTOMIZING_DATA
*&----------------------------------------------------------*
* GET_CUSTOMIZING_DATA
*& ---------------------------------------------------------*
FORM GET_CUSTOMIZING_DATA.
CALL FUNCTION 'ARCHIVE_GET_CUSTOMIZING_DATA'
EXPORTING
object = c_object
IMPORTING
COMMIT_COUNT_FOR_DELETE_PRG = V_COMMIT_CNT
EXCEPTIONS
OBJECT_NOT_FOUND = 1
OTHERS = 2.
IF SY-SUBRC > C_0.
MESSAGE I001 WITH C_MSG2.
EXIT.
ENDIF.
ENDFORM.
*& ---------------------------------------------------------*
*& Form GET_ARCHIVE_FILE
*&----------------------------------------------------------*
* GET_ARCHIVE_FILE
*& ---------------------------------------------------------*
FORM GET_ARCHIVE_FILE.
CALL FUNCTION 'ARCHIVE_GET_ARCHIVE_FILES'
EXPORTING
ARCHIVE_HANDLE = V_READ_HANDLE
TABLES
ARCHIVE_FILES = I_SEL_FILES_ITAB
EXCEPTIONS
WRONG_ACCESS_TO_ARCHIVE = 1
INTERNAL_ERROR = 2
OTHERS = 3.
IF SY-SUBRC <> C_0.
MESSAGE I001 WITH C_MSG3.
EXIT.
ENDIF.
ENDFORM.
*& ---------------------------------------------------------*
*& Form WRITE_STATISTICS
*&----------------------------------------------------------*
* Set administration status and write statistics
*& ---------------------------------------------------------*
FORM WRITE_STATISTICS.
IF TESTRUN IS INITIAL.
CALL FUNCTION 'ARCHIVE_ADMIN_SET_STATUS'
EXPORTING
FILES_ARE_CONVERTED = C_SPACE
INDEX_DELETED = C_X
TABLES
ARCHIVE_FILES = I_SEL_FILES_ITAB
EXCEPTIONS
CANNOT_CHANGE_STATUS = 1
OTHERS = 2.
ENDIF.
IF V_DUPREC <> C_SPACE.
WRITE:/ C_TEXT1.
ENDIF.
ULINE. WRITE:/ C_TEXT2. ULINE.
WRITE:/ V_READ_CNT, C_TEXT3.
WRITE:/ V_RELOAD_CNT, C_TEXT4.
ENDFORM.
*& ---------------------------------------------------------*
*& Form DELETE_INDEX_TAB
*&----------------------------------------------------------*
* DELETE_INDEX_TAB
*& ---------------------------------------------------------*
FORM DELETE_INDEX_TAB.
IF TESTRUN IS INITIAL.
DELETE ARCH_IDX_S FROM TABLE I_INDEX_TAB.
ENDIF.
REFRESH I_INDEX_TAB.
ENDFORM.
*& ---------------------------------------------------------*
*& Form INSERT_FROM_TABLE
*&----------------------------------------------------------*
* INSERT_FROM_TABLE
*& ---------------------------------------------------------*
FORM INSERT_FROM_TABLE.
IF TESTRUN IS INITIAL.
INSERT YAPTMAIN FROM TABLE I_YAPTMAIN
ACCEPTING DUPLICATE KEYS.
IF SY-SUBRC = C_4.
V_DUPREC = C_X.
ENDIF.
ADD SY-DBCNT TO V_RELOAD_CNT.
ENDIF.
COMMIT WORK.
ENDFORM.
*& ---------------------------------------------------------*
*& Form POPULATE_LAYOUT
*&----------------------------------------------------------*
* POPULATE_LAYOUT
*& ---------------------------------------------------------*
FORM POPULATE_LAYOUT.
CLEAR X_LAYOUT.
X_LAYOUT-ZEBRA = C_X.
X_LAYOUT-DETAIL_POPUP = C_X.
X_LAYOUT-DETAIL_INITIAL_LINES = C_X.
ENDFORM.
*& ---------------------------------------------------------*
*& Form OUTPUT_DATA_USING_ALV
*&----------------------------------------------------------*
* OUTPUT_DATA_USING_ALV
*& ---------------------------------------------------------*
FORM OUTPUT_DATA_USING_ALV.
PERFORM CALL_BLOCK_UNIT.
PERFORM APPEND_ITABS_TO_ALV_STRUC.
ENDFORM.
*& ---------------------------------------------------------*
*& Form CALL_BLOCK_UNIT
*&----------------------------------------------------------*
* CALL_BLOCK_UNIT
*& ---------------------------------------------------------*
FORM CALL_BLOCK_UNIT.
DATA: V_REPID LIKE SY-REPID.
V_REPID = SY-REPID.
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_INIT'
EXPORTING
I_CALLBACK_PROGRAM = V_REPID.
ENDFORM.
*& ---------------------------------------------------------*
*& Form APPEND_ITABS_TO_ALV_STRUC
*&----------------------------------------------------------*
* APPEND_ITABS_TO_ALV_STRUC
*& ---------------------------------------------------------*
FORM APPEND_ITABS_TO_ALV_STRUC.
DATA: X_EVENTS TYPE SLIS_ALV_EVENT.
*- Append YAPTMAIN to ALV Structure.
IF NOT I_YAPTMAIN[] IS INITIAL.
*- Populate Field Catalogs Table.
CLEAR: I_FIELDCAT.
REFRESH: I_FIELDCAT.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_STRUCTURE_NAME = C_TABLE
I_CLIENT_NEVER_DISPLAY = C_X
CHANGING
CT_FIELDCAT = I_FIELDCAT.
*- Populate Events Table.
CLEAR I_EVENTS.
REFRESH I_EVENTS.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
I_LIST_TYPE = 0
IMPORTING
ET_EVENTS = I_EVENTS
EXCEPTIONS
LIST_TYPE_WRONG = 1
OTHERS = 2.
IF SY-SUBRC EQ C_0.
READ TABLE I_EVENTS WITH KEY NAME = C_TOP_OF_LIST INTO X_EVENTS.
IF SY-SUBRC EQ C_0.
MOVE C_TOP_OF_LIST_YAPTMAIN TO X_EVENTS-FORM.
MODIFY I_EVENTS FROM X_EVENTS INDEX SY-TABIX.
ENDIF.
ENDIF.
*- Call Function to append to ALV List.
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
EXPORTING
IS_LAYOUT = X_LAYOUT
IT_FIELDCAT = I_FIELDCAT
I_TABNAME = V_I_TAB
IT_EVENTS = I_EVENTS
TABLES
T_OUTTAB = I_YAPTMAIN
EXCEPTIONS
PROGRAM_ERROR = 1
MAXIMUM_OF_APPENDS_REACHED = 2
OTHERS = 3.
ENDIF.
*- Call ALV Function for List Display.
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_DISPLAY'
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
ENDFORM.
*& ---------------------------------------------------------*
*& Form CLOSE_ARCHIVE_FILE
*&----------------------------------------------------------*
* CLOSE_ARCHIVE_FILE
*& ---------------------------------------------------------*
FORM CLOSE_ARCHIVE_FILE.
CALL FUNCTION 'ARCHIVE_CLOSE_FILE'
EXPORTING
ARCHIVE_HANDLE = V_READ_HANDLE
EXCEPTIONS
INTERNAL_ERROR = 1
WRONG_ACCESS_TO_ARCHIVE = 2
OTHERS = 3.
IF SY-SUBRC <> C_0.
MESSAGE I001 WITH 'Unable to close archive session'.
EXIT.
ENDIF.
ENDFORM.
*& ---------------------------------------------------------*
*& Form TOP_OF_LIST
*&----------------------------------------------------------*
* TOP_OF_LIST
*& ---------------------------------------------------------*
FORM TOP_OF_LIST_YAPTMAIN.
WRITE: /30 C_TEXT5.
ULINE.
WRITE: /.
WRITE: / C_TEXT6.
ENDFORM.
*& ---------------------------------------------------------*
*& Form GET_SELECTION_TEXTS
*&----------------------------------------------------------*
* GET_SELECTION_TEXTS
*& ---------------------------------------------------------*
FORM GET_SELECTION_TEXTS.
V_TEST = C_TEXT7.
ENDFORM.
NO STANDARD PAGE HEADING
LINE-SIZE 255.
*- Tables Declarations.
TABLES: YAPTMAIN.
TYPE-POOLS SLIS.
*- Internal Table Declarations....................................
DATA: BEGIN OF I_YAPTMAIN OCCURS 0.
INCLUDE STRUCTURE YAPTMAIN .
DATA: END OF I_YAPTMAIN.
DATA: I_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV.
DATA: I_EVENTS TYPE SLIS_T_EVENT.
DATA: I_INDEX_TAB TYPE TABLE OF ARCH_IDX_S WITH HEADER LINE.
DATA: I_SEL_FILES_ITAB TYPE TABLE OF ARCH_FILES.
*- Structures.......................................................
DATA: BEGIN OF K_BUFFER.
INCLUDE STRUCTURE arc_buffer.
DATA: END OF K_BUFFER,
K_TABLE_WA LIKE YAPTMAIN.
*- Structure for Layout.
DATA: X_LAYOUT TYPE SLIS_LAYOUT_ALV.
DATA:V_READ_HANDLE LIKE sy-tabix,
v_exi TYPE c,
v_x TYPE c VALUE 'X',
v_returncode TYPE c,
V_COMMIT_CNT LIKE ARCH_USR-ARCH_COMIT,
V_OBJECT_CNT TYPE I,
V_READ_CNT TYPE I,
V_RELOAD_CNT TYPE I,
V_ARKEY LIKE ARCH_IDX_S-ARCHIVEKEY,
V_OBJECT_ID LIKE ARCH_IDX_S-OBJ_ID,
V_OFFSET LIKE ARCH_IDX_S-OBJ_OFFSET,
V_DUPREC TYPE C,
V_I_TAB TYPE SLIS_TABNAME.
*--Constants........................................................
CONSTANTS: C_0 VALUE 0,
C_SPACE VALUE SPACE,
C_1 VALUE 1,
C_4 VALUE 4,
C_X VALUE 'X',
C_TOP_OF_LIST(15) VALUE 'TOP_OF_LIST',
C_TOP_OF_LIST_YAPTMAIN(35) VALUE 'TOP_OF_LIST_YAPTMAIN',
C_I_YAPTMAIN(35) VALUE 'I_YAPTMAIN',
C_MSG1(25) VALUE 'No file can be accessed',
C_MSG2(40) VALUE 'Unable to access customizing data',
C_MSG3(25) VALUE 'Unable to Process Files',
C_TEXT1(25) VALUE 'There were duplicate keys',
C_TEXT2(25) VALUE 'RELOADED ARCHIVE INFO:',
C_TEXT3(25) VALUE 'Data Objects Read',
C_TEXT4(25) VALUE 'Data Objects Reloaded',
C_TEXT5(50) VALUE ' Reloaded Records for Object - YARCHTEST ' ,
C_TEXT6(50) VALUE ' YAPTMAIN - Archive Objects Information ' ,
C_TEXT7(15) VALUE 'Test Run',
C_TABLE(30) VALUE 'YAPTMAIN',
C_OBJECT(10) VALUE 'YARCHTEST'.
*- Selection Screen.
SELECTION-SCREEN BEGIN OF BLOCK B2 WITH FRAME TITLE V_TEXT2.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT (29) V_TEST.
PARAMETERS: TESTRUN DEFAULT'X' AS CHECKBOX.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK B2.
INITIALIZATION.
SY-TITLE = ' Reload Records for Object - YARCHTEST'.
V_TEXT2 = 'Test Run'.
CONCATENATE '''' C_I_YAPTMAIN '''' INTO V_I_TAB.
CONDENSE V_I_TAB NO-GAPS.
*- Get Selection Screen Texts.
PERFORM GET_SELECTION_TEXTS.
*- Popuate the layout structure for display.
PERFORM POPULATE_LAYOUT.
START-OF-SELECTION.
PERFORM OPEN_ARCHIVE_FILE.
PERFORM GET_CUSTOMIZING_DATA.
CLEAR: V_OBJECT_CNT, V_DUPREC, V_READ_CNT, V_RELOAD_CNT.
DO.
ADD 1 TO V_OBJECT_CNT.
CALL FUNCTION 'ARCHIVE_GET_NEXT_OBJECT'
EXPORTING
ARCHIVE_HANDLE = V_READ_HANDLE
IMPORTING
OBJECT_ID = V_OBJECT_ID
OBJECT_OFFSET = V_OFFSET
ARCHIVE_NAME = V_ARKEY
EXCEPTIONS
END_OF_FILE = 1
FILE_IO_ERROR = 2
INTERNAL_ERROR = 3
OPEN_ERROR = 4
WRONG_ACCESS_TO_ARCHIVE = 5
OTHERS = 6.
IF SY-SUBRC <> C_0.
EXIT.
ENDIF.
ADD 1 TO V_READ_CNT.
MOVE: V_OBJECT_ID TO I_INDEX_TAB-OBJ_ID,
V_ARKEY TO I_INDEX_TAB-ARCHIVEKEY,
V_OFFSET TO I_INDEX_TAB-OBJ_OFFSET.
APPEND I_INDEX_TAB.
PERFORM DELETE_INDEX_TAB ON COMMIT.
DO.
CALL FUNCTION 'ARCHIVE_GET_NEXT_RECORD'
EXPORTING
ARCHIVE_HANDLE = V_READ_HANDLE
IMPORTING
RECORD = K_BUFFER-SEGMENT
RECORD_STRUCTURE = K_BUFFER-RNAME
EXCEPTIONS
END_OF_OBJECT = 1
INTERNAL_ERROR = 2
WRONG_ACCESS_TO_ARCHIVE = 3
OTHERS = 4.
IF SY-SUBRC <> C_0.
EXIT.
ENDIF.
CASE K_BUFFER-rname.
WHEN C_TABLE.
MOVE K_BUFFER-SEGMENT TO K_TABLE_WA.
APPEND K_TABLE_WA TO I_YAPTMAIN.
ENDCASE.
ENDDO.
IF V_OBJECT_CNT = V_COMMIT_CNT.
PERFORM INSERT_FROM_TABLE.
CLEAR V_OBJECT_CNT.
ENDIF.
ENDDO.
IF V_OBJECT_CNT > C_1.
PERFORM INSERT_FROM_TABLE.
ENDIF.
PERFORM GET_ARCHIVE_FILE.
PERFORM CLOSE_ARCHIVE_FILE.
END-OF-SELECTION.
PERFORM WRITE_STATISTICS.
*- Output the data using ALV.
PERFORM OUTPUT_DATA_USING_ALV.
*& ---------------------------------------------------------*
*& Form ARCHIVE_OPEN_FOR_READ
*&----------------------------------------------------------*
* ARCHIVE_OPEN_FOR_READ
*& ---------------------------------------------------------*
FORM OPEN_ARCHIVE_FILE.
CALL FUNCTION 'ARCHIVE_OPEN_FOR_MOVE'
EXPORTING
object = C_OBJECT
TEST_MODE = TESTRUN
IMPORTING
archive_READ_handle = V_READ_HANDLE
EXCEPTIONS
file_already_open = 1
FILE_IO_ERROR = 2
INTERNAL_ERROR = 3
NO_FILES_AVAILABLE = 4
OBJECT_NOT_FOUND = 5
OPEN_ERROR = 6
NOT_AUTHORIZED = 7
OTHERS = 8.
IF SY-SUBRC > C_0.
MESSAGE I001 WITH C_MSG1.
EXIT.
ENDIF.
ENDFORM.
*& ---------------------------------------------------------*
*& Form GET_CUSTOMIZING_DATA
*&----------------------------------------------------------*
* GET_CUSTOMIZING_DATA
*& ---------------------------------------------------------*
FORM GET_CUSTOMIZING_DATA.
CALL FUNCTION 'ARCHIVE_GET_CUSTOMIZING_DATA'
EXPORTING
object = c_object
IMPORTING
COMMIT_COUNT_FOR_DELETE_PRG = V_COMMIT_CNT
EXCEPTIONS
OBJECT_NOT_FOUND = 1
OTHERS = 2.
IF SY-SUBRC > C_0.
MESSAGE I001 WITH C_MSG2.
EXIT.
ENDIF.
ENDFORM.
*& ---------------------------------------------------------*
*& Form GET_ARCHIVE_FILE
*&----------------------------------------------------------*
* GET_ARCHIVE_FILE
*& ---------------------------------------------------------*
FORM GET_ARCHIVE_FILE.
CALL FUNCTION 'ARCHIVE_GET_ARCHIVE_FILES'
EXPORTING
ARCHIVE_HANDLE = V_READ_HANDLE
TABLES
ARCHIVE_FILES = I_SEL_FILES_ITAB
EXCEPTIONS
WRONG_ACCESS_TO_ARCHIVE = 1
INTERNAL_ERROR = 2
OTHERS = 3.
IF SY-SUBRC <> C_0.
MESSAGE I001 WITH C_MSG3.
EXIT.
ENDIF.
ENDFORM.
*& ---------------------------------------------------------*
*& Form WRITE_STATISTICS
*&----------------------------------------------------------*
* Set administration status and write statistics
*& ---------------------------------------------------------*
FORM WRITE_STATISTICS.
IF TESTRUN IS INITIAL.
CALL FUNCTION 'ARCHIVE_ADMIN_SET_STATUS'
EXPORTING
FILES_ARE_CONVERTED = C_SPACE
INDEX_DELETED = C_X
TABLES
ARCHIVE_FILES = I_SEL_FILES_ITAB
EXCEPTIONS
CANNOT_CHANGE_STATUS = 1
OTHERS = 2.
ENDIF.
IF V_DUPREC <> C_SPACE.
WRITE:/ C_TEXT1.
ENDIF.
ULINE. WRITE:/ C_TEXT2. ULINE.
WRITE:/ V_READ_CNT, C_TEXT3.
WRITE:/ V_RELOAD_CNT, C_TEXT4.
ENDFORM.
*& ---------------------------------------------------------*
*& Form DELETE_INDEX_TAB
*&----------------------------------------------------------*
* DELETE_INDEX_TAB
*& ---------------------------------------------------------*
FORM DELETE_INDEX_TAB.
IF TESTRUN IS INITIAL.
DELETE ARCH_IDX_S FROM TABLE I_INDEX_TAB.
ENDIF.
REFRESH I_INDEX_TAB.
ENDFORM.
*& ---------------------------------------------------------*
*& Form INSERT_FROM_TABLE
*&----------------------------------------------------------*
* INSERT_FROM_TABLE
*& ---------------------------------------------------------*
FORM INSERT_FROM_TABLE.
IF TESTRUN IS INITIAL.
INSERT YAPTMAIN FROM TABLE I_YAPTMAIN
ACCEPTING DUPLICATE KEYS.
IF SY-SUBRC = C_4.
V_DUPREC = C_X.
ENDIF.
ADD SY-DBCNT TO V_RELOAD_CNT.
ENDIF.
COMMIT WORK.
ENDFORM.
*& ---------------------------------------------------------*
*& Form POPULATE_LAYOUT
*&----------------------------------------------------------*
* POPULATE_LAYOUT
*& ---------------------------------------------------------*
FORM POPULATE_LAYOUT.
CLEAR X_LAYOUT.
X_LAYOUT-ZEBRA = C_X.
X_LAYOUT-DETAIL_POPUP = C_X.
X_LAYOUT-DETAIL_INITIAL_LINES = C_X.
ENDFORM.
*& ---------------------------------------------------------*
*& Form OUTPUT_DATA_USING_ALV
*&----------------------------------------------------------*
* OUTPUT_DATA_USING_ALV
*& ---------------------------------------------------------*
FORM OUTPUT_DATA_USING_ALV.
PERFORM CALL_BLOCK_UNIT.
PERFORM APPEND_ITABS_TO_ALV_STRUC.
ENDFORM.
*& ---------------------------------------------------------*
*& Form CALL_BLOCK_UNIT
*&----------------------------------------------------------*
* CALL_BLOCK_UNIT
*& ---------------------------------------------------------*
FORM CALL_BLOCK_UNIT.
DATA: V_REPID LIKE SY-REPID.
V_REPID = SY-REPID.
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_INIT'
EXPORTING
I_CALLBACK_PROGRAM = V_REPID.
ENDFORM.
*& ---------------------------------------------------------*
*& Form APPEND_ITABS_TO_ALV_STRUC
*&----------------------------------------------------------*
* APPEND_ITABS_TO_ALV_STRUC
*& ---------------------------------------------------------*
FORM APPEND_ITABS_TO_ALV_STRUC.
DATA: X_EVENTS TYPE SLIS_ALV_EVENT.
*- Append YAPTMAIN to ALV Structure.
IF NOT I_YAPTMAIN[] IS INITIAL.
*- Populate Field Catalogs Table.
CLEAR: I_FIELDCAT.
REFRESH: I_FIELDCAT.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_STRUCTURE_NAME = C_TABLE
I_CLIENT_NEVER_DISPLAY = C_X
CHANGING
CT_FIELDCAT = I_FIELDCAT.
*- Populate Events Table.
CLEAR I_EVENTS.
REFRESH I_EVENTS.
CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
EXPORTING
I_LIST_TYPE = 0
IMPORTING
ET_EVENTS = I_EVENTS
EXCEPTIONS
LIST_TYPE_WRONG = 1
OTHERS = 2.
IF SY-SUBRC EQ C_0.
READ TABLE I_EVENTS WITH KEY NAME = C_TOP_OF_LIST INTO X_EVENTS.
IF SY-SUBRC EQ C_0.
MOVE C_TOP_OF_LIST_YAPTMAIN TO X_EVENTS-FORM.
MODIFY I_EVENTS FROM X_EVENTS INDEX SY-TABIX.
ENDIF.
ENDIF.
*- Call Function to append to ALV List.
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
EXPORTING
IS_LAYOUT = X_LAYOUT
IT_FIELDCAT = I_FIELDCAT
I_TABNAME = V_I_TAB
IT_EVENTS = I_EVENTS
TABLES
T_OUTTAB = I_YAPTMAIN
EXCEPTIONS
PROGRAM_ERROR = 1
MAXIMUM_OF_APPENDS_REACHED = 2
OTHERS = 3.
ENDIF.
*- Call ALV Function for List Display.
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_DISPLAY'
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
ENDFORM.
*& ---------------------------------------------------------*
*& Form CLOSE_ARCHIVE_FILE
*&----------------------------------------------------------*
* CLOSE_ARCHIVE_FILE
*& ---------------------------------------------------------*
FORM CLOSE_ARCHIVE_FILE.
CALL FUNCTION 'ARCHIVE_CLOSE_FILE'
EXPORTING
ARCHIVE_HANDLE = V_READ_HANDLE
EXCEPTIONS
INTERNAL_ERROR = 1
WRONG_ACCESS_TO_ARCHIVE = 2
OTHERS = 3.
IF SY-SUBRC <> C_0.
MESSAGE I001 WITH 'Unable to close archive session'.
EXIT.
ENDIF.
ENDFORM.
*& ---------------------------------------------------------*
*& Form TOP_OF_LIST
*&----------------------------------------------------------*
* TOP_OF_LIST
*& ---------------------------------------------------------*
FORM TOP_OF_LIST_YAPTMAIN.
WRITE: /30 C_TEXT5.
ULINE.
WRITE: /.
WRITE: / C_TEXT6.
ENDFORM.
*& ---------------------------------------------------------*
*& Form GET_SELECTION_TEXTS
*&----------------------------------------------------------*
* GET_SELECTION_TEXTS
*& ---------------------------------------------------------*
FORM GET_SELECTION_TEXTS.
V_TEST = C_TEXT7.
ENDFORM.
ABAP - Program For Archiving A Table
REPORT YARCHTEST_ARC MESSAGE-ID YAPK
NO STANDARD PAGE HEADING
LINE-SIZE 255.
*- Tables Declarations.
TABLES: YAPTMAIN.
*- Internal Tables Declarations.
DATA: BEGIN OF I_YAPTMAIN OCCURS 0.
INCLUDE STRUCTURE YAPTMAIN .
DATA: END OF I_YAPTMAIN.
*- Data Type Declarations.
DATA:
V_BUTTON(1) TYPE C,
V_HANDLE LIKE SY-TABIX,
V_CREATE(1) TYPE C VALUE 'X',
V_NO_DELETE(1) TYPE C VALUE 'X',
V_DATA_OBJECT_ID LIKE ARCH_IDX_S-OBJ_ID,
V_COUNT(10) TYPE N.
*- Constants.
CONSTANTS:
C_X VALUE 'X',
C_SPACE VALUE '',
C_NOFILE(30) VALUE 'Donot Create Archive File',
C_DTEST(30) VALUE 'Delete Job in Test Mode',
C_DPROD(30) VALUE 'Delete Program',
C_OBJECT(10) VALUE 'YARCHTEST',
C_TABLE(30) VALUE 'YAPTMAIN',
C_0 VALUE 0,
C_TEXT1(70) VALUE 'Created by ArchivePac',
C_MSG1(70) VALUE 'Unable to open archive session for Archive object',
C_MSG2(70) VALUE 'Unable to Access Archive object',
C_MSG3(70) VALUE 'Invalid record structure',
C_MSG4(70) VALUE 'Unable to write data to archive file',
C_MSG5(70) VALUE 'Unable to create spool list',
C_MSG6(70) VALUE 'Unable to close archive session'.
*- Selection Screen.
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE V_TEXT1.
SELECT-OPTIONS: S_ARCH01 FOR YAPTMAIN-ARCHDATE.
SELECT-OPTIONS: S_ARCH02 FOR YAPTMAIN-ARCH_COMP.
SELECT-OPTIONS: S_ARCH03 FOR YAPTMAIN-ARCH_FREQ.
SELECTION-SCREEN END OF BLOCK B1.
SELECTION-SCREEN BEGIN OF BLOCK B2 WITH FRAME TITLE V_TEXT2.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT (29) V_NOFILE.
PARAMETERS: NO_FILE LIKE V_BUTTON RADIOBUTTON GROUP RADI.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT (29) V_DTEST.
PARAMETERS: DEL_TEST LIKE V_BUTTON RADIOBUTTON GROUP RADI.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT (29) V_DPROD.
PARAMETERS: DEL_PROD LIKE V_BUTTON RADIOBUTTON GROUP RADI.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK B2.
INITIALIZATION.
SY-TITLE = ' Archive Program for Table - YAPTMAIN'.
V_TEXT1 = 'Selection Details'.
*- Get Selection Screen Texts.
PERFORM GET_SELECTION_TEXTS.
START-OF-SELECTION.
PERFORM BUILD_ADK_PARAMETERS.
PERFORM GET_ARCHIVE_DATA.
PERFORM OPEN_ARCHIVE.
PERFORM WRITE_ARCHIVE_RECORDS TABLES I_YAPTMAIN
USING C_TABLE.
END-OF-SELECTION.
PERFORM WRITE_STATISTICS.
PERFORM CLOSE_ARCHIVE_FILE.
*& ---------------------------------------------------------*
*& Form BUILD_ADK_PARAMETERS
*&---------------------------------------------------------*
* Build parameters for Archiving Object
*&-----------------------------------------------------------*
FORM BUILD_ADK_PARAMETERS.
* build ADK parameters from chosen button
IF NO_FILE = C_X.
V_CREATE = C_SPACE.
V_NO_DELETE = C_SPACE.
ENDIF.
IF DEL_TEST = C_X.
V_CREATE = C_X.
V_NO_DELETE = C_X.
ENDIF.
IF DEL_PROD = C_X.
V_CREATE = C_X.
V_NO_DELETE = C_SPACE.
ENDIF.
ENDFORM.
*& ---------------------------------------------------------*
*& Form GET_ARCHIVE_DATA
*& ---------------------------------------------------------*
* Get relevant archive data from the database
*& ---------------------------------------------------------*
FORM GET_ARCHIVE_DATA.
* Select data to be archived
SELECT * FROM YAPTMAIN INTO TABLE I_YAPTMAIN WHERE
ARCHDATE IN S_ARCH01 AND
ARCH_COMP IN S_ARCH02 AND
ARCH_FREQ IN S_ARCH03.
ENDFORM.
*& ---------------------------------------------------------*
*& Form OPEN_ARCHIVE
*& ---------------------------------------------------------*
* Open Archive for writing data
*& ---------------------------------------------------------*
FORM OPEN_ARCHIVE.
* open a new archive session to archive data
CALL FUNCTION 'ARCHIVE_OPEN_FOR_WRITE'
EXPORTING
CALL_DELETE_JOB_IN_TEST_MODE = V_NO_DELETE
CREATE_ARCHIVE_FILE = V_CREATE
OBJECT = C_OBJECT
COMMENTS = C_TEXT1
IMPORTING
ARCHIVE_HANDLE = V_HANDLE
EXCEPTIONS
INTERNAL_ERROR = 1
OBJECT_NOT_FOUND = 2
OPEN_ERROR = 3
NOT_AUTHORIZED = 4
OTHERS = 5.
IF SY-SUBRC <> C_0.
MESSAGE E001 WITH C_MSG1.
ENDIF.
ENDFORM.
*& ---------------------------------------------------------*
*& Form WRITE_ARCHIVE_RECORDS
*& ---------------------------------------------------------*
* Write Archive records to archive file
*& ---------------------------------------------------------*
FORM WRITE_ARCHIVE_RECORDS TABLES P_TABLE
USING VALUE(P_STRUC).
* close the archive session
SORT P_TABLE.
LOOP AT P_TABLE.
V_COUNT = V_COUNT + 1.
CONCATENATE SY-MANDT V_COUNT INTO V_DATA_OBJECT_ID.
* initialize a new data object
CALL FUNCTION 'ARCHIVE_NEW_OBJECT'
EXPORTING
ARCHIVE_HANDLE = V_HANDLE
OBJECT_ID = V_DATA_OBJECT_ID
EXCEPTIONS
INTERNAL_ERROR = 1
WRONG_ACCESS_TO_ARCHIVE = 2
OTHERS = 3.
IF SY-SUBRC <> C_0.
MESSAGE I001 WITH C_MSG2.
EXIT.
ENDIF.
* put data records into ADKS data container
CALL FUNCTION 'ARCHIVE_PUT_RECORD'
EXPORTING
ARCHIVE_HANDLE = V_HANDLE
RECORD = P_TABLE
RECORD_STRUCTURE = P_STRUC
EXCEPTIONS
INTERNAL_ERROR = 1
WRONG_ACCESS_TO_ARCHIVE = 2
INVALID_RECORD_STRUCTURE = 3
OTHERS = 4.
IF SY-SUBRC <> C_0.
MESSAGE I001 WITH C_MSG3.
EXIT.
ENDIF.
* write data object into the archive file
CALL FUNCTION 'ARCHIVE_SAVE_OBJECT'
EXPORTING
ARCHIVE_HANDLE = V_HANDLE
EXCEPTIONS
FILE_IO_ERROR = 1
INTERNAL_ERROR = 2
OPEN_ERROR = 3
TERMINATION_REQUESTED = 4
WRONG_ACCESS_TO_ARCHIVE = 5
OTHERS = 6.
IF SY-SUBRC <> C_0.
MESSAGE I001 WITH C_MSG4.
EXIT.
ENDIF.
ENDLOOP.
ENDFORM.
*& ---------------------------------------------------------*
*& Form WRITE_STATISTICS
*& ---------------------------------------------------------*
* Write Archive File statistics
*& ---------------------------------------------------------*
FORM WRITE_STATISTICS.
* create the default spool list
CALL FUNCTION 'ARCHIVE_WRITE_STATISTICS'
EXPORTING
ARCHIVE_HANDLE = V_HANDLE
EXCEPTIONS
INTERNAL_ERROR = 1
OTHERS = 2.
IF SY-SUBRC <> C_0.
MESSAGE I001 WITH C_MSG5.
EXIT.
ENDIF.
ENDFORM.
*& ---------------------------------------------------------*
*& Form CLOSE_ARCHIVE_FILE
*& -------------------------------------------------- *
* Close Archive File
*& ---------------------------------------------------------*
FORM CLOSE_ARCHIVE_FILE.
* close the archive session
CALL FUNCTION 'ARCHIVE_CLOSE_FILE'
EXPORTING
ARCHIVE_HANDLE = V_HANDLE
EXCEPTIONS
INTERNAL_ERROR = 1
WRONG_ACCESS_TO_ARCHIVE = 2
OTHERS = 3.
IF SY-SUBRC <> C_0.
MESSAGE I001 WITH C_MSG6.
EXIT.
ENDIF.
ENDFORM.
FORM GET_SELECTION_TEXTS.
V_NOFILE = C_NOFILE.
V_DTEST = C_DTEST.
V_DPROD = C_DPROD.
ENDFORM.
NO STANDARD PAGE HEADING
LINE-SIZE 255.
*- Tables Declarations.
TABLES: YAPTMAIN.
*- Internal Tables Declarations.
DATA: BEGIN OF I_YAPTMAIN OCCURS 0.
INCLUDE STRUCTURE YAPTMAIN .
DATA: END OF I_YAPTMAIN.
*- Data Type Declarations.
DATA:
V_BUTTON(1) TYPE C,
V_HANDLE LIKE SY-TABIX,
V_CREATE(1) TYPE C VALUE 'X',
V_NO_DELETE(1) TYPE C VALUE 'X',
V_DATA_OBJECT_ID LIKE ARCH_IDX_S-OBJ_ID,
V_COUNT(10) TYPE N.
*- Constants.
CONSTANTS:
C_X VALUE 'X',
C_SPACE VALUE '',
C_NOFILE(30) VALUE 'Donot Create Archive File',
C_DTEST(30) VALUE 'Delete Job in Test Mode',
C_DPROD(30) VALUE 'Delete Program',
C_OBJECT(10) VALUE 'YARCHTEST',
C_TABLE(30) VALUE 'YAPTMAIN',
C_0 VALUE 0,
C_TEXT1(70) VALUE 'Created by ArchivePac',
C_MSG1(70) VALUE 'Unable to open archive session for Archive object',
C_MSG2(70) VALUE 'Unable to Access Archive object',
C_MSG3(70) VALUE 'Invalid record structure',
C_MSG4(70) VALUE 'Unable to write data to archive file',
C_MSG5(70) VALUE 'Unable to create spool list',
C_MSG6(70) VALUE 'Unable to close archive session'.
*- Selection Screen.
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE V_TEXT1.
SELECT-OPTIONS: S_ARCH01 FOR YAPTMAIN-ARCHDATE.
SELECT-OPTIONS: S_ARCH02 FOR YAPTMAIN-ARCH_COMP.
SELECT-OPTIONS: S_ARCH03 FOR YAPTMAIN-ARCH_FREQ.
SELECTION-SCREEN END OF BLOCK B1.
SELECTION-SCREEN BEGIN OF BLOCK B2 WITH FRAME TITLE V_TEXT2.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT (29) V_NOFILE.
PARAMETERS: NO_FILE LIKE V_BUTTON RADIOBUTTON GROUP RADI.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT (29) V_DTEST.
PARAMETERS: DEL_TEST LIKE V_BUTTON RADIOBUTTON GROUP RADI.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT (29) V_DPROD.
PARAMETERS: DEL_PROD LIKE V_BUTTON RADIOBUTTON GROUP RADI.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK B2.
INITIALIZATION.
SY-TITLE = ' Archive Program for Table - YAPTMAIN'.
V_TEXT1 = 'Selection Details'.
*- Get Selection Screen Texts.
PERFORM GET_SELECTION_TEXTS.
START-OF-SELECTION.
PERFORM BUILD_ADK_PARAMETERS.
PERFORM GET_ARCHIVE_DATA.
PERFORM OPEN_ARCHIVE.
PERFORM WRITE_ARCHIVE_RECORDS TABLES I_YAPTMAIN
USING C_TABLE.
END-OF-SELECTION.
PERFORM WRITE_STATISTICS.
PERFORM CLOSE_ARCHIVE_FILE.
*& ---------------------------------------------------------*
*& Form BUILD_ADK_PARAMETERS
*&---------------------------------------------------------*
* Build parameters for Archiving Object
*&-----------------------------------------------------------*
FORM BUILD_ADK_PARAMETERS.
* build ADK parameters from chosen button
IF NO_FILE = C_X.
V_CREATE = C_SPACE.
V_NO_DELETE = C_SPACE.
ENDIF.
IF DEL_TEST = C_X.
V_CREATE = C_X.
V_NO_DELETE = C_X.
ENDIF.
IF DEL_PROD = C_X.
V_CREATE = C_X.
V_NO_DELETE = C_SPACE.
ENDIF.
ENDFORM.
*& ---------------------------------------------------------*
*& Form GET_ARCHIVE_DATA
*& ---------------------------------------------------------*
* Get relevant archive data from the database
*& ---------------------------------------------------------*
FORM GET_ARCHIVE_DATA.
* Select data to be archived
SELECT * FROM YAPTMAIN INTO TABLE I_YAPTMAIN WHERE
ARCHDATE IN S_ARCH01 AND
ARCH_COMP IN S_ARCH02 AND
ARCH_FREQ IN S_ARCH03.
ENDFORM.
*& ---------------------------------------------------------*
*& Form OPEN_ARCHIVE
*& ---------------------------------------------------------*
* Open Archive for writing data
*& ---------------------------------------------------------*
FORM OPEN_ARCHIVE.
* open a new archive session to archive data
CALL FUNCTION 'ARCHIVE_OPEN_FOR_WRITE'
EXPORTING
CALL_DELETE_JOB_IN_TEST_MODE = V_NO_DELETE
CREATE_ARCHIVE_FILE = V_CREATE
OBJECT = C_OBJECT
COMMENTS = C_TEXT1
IMPORTING
ARCHIVE_HANDLE = V_HANDLE
EXCEPTIONS
INTERNAL_ERROR = 1
OBJECT_NOT_FOUND = 2
OPEN_ERROR = 3
NOT_AUTHORIZED = 4
OTHERS = 5.
IF SY-SUBRC <> C_0.
MESSAGE E001 WITH C_MSG1.
ENDIF.
ENDFORM.
*& ---------------------------------------------------------*
*& Form WRITE_ARCHIVE_RECORDS
*& ---------------------------------------------------------*
* Write Archive records to archive file
*& ---------------------------------------------------------*
FORM WRITE_ARCHIVE_RECORDS TABLES P_TABLE
USING VALUE(P_STRUC).
* close the archive session
SORT P_TABLE.
LOOP AT P_TABLE.
V_COUNT = V_COUNT + 1.
CONCATENATE SY-MANDT V_COUNT INTO V_DATA_OBJECT_ID.
* initialize a new data object
CALL FUNCTION 'ARCHIVE_NEW_OBJECT'
EXPORTING
ARCHIVE_HANDLE = V_HANDLE
OBJECT_ID = V_DATA_OBJECT_ID
EXCEPTIONS
INTERNAL_ERROR = 1
WRONG_ACCESS_TO_ARCHIVE = 2
OTHERS = 3.
IF SY-SUBRC <> C_0.
MESSAGE I001 WITH C_MSG2.
EXIT.
ENDIF.
* put data records into ADKS data container
CALL FUNCTION 'ARCHIVE_PUT_RECORD'
EXPORTING
ARCHIVE_HANDLE = V_HANDLE
RECORD = P_TABLE
RECORD_STRUCTURE = P_STRUC
EXCEPTIONS
INTERNAL_ERROR = 1
WRONG_ACCESS_TO_ARCHIVE = 2
INVALID_RECORD_STRUCTURE = 3
OTHERS = 4.
IF SY-SUBRC <> C_0.
MESSAGE I001 WITH C_MSG3.
EXIT.
ENDIF.
* write data object into the archive file
CALL FUNCTION 'ARCHIVE_SAVE_OBJECT'
EXPORTING
ARCHIVE_HANDLE = V_HANDLE
EXCEPTIONS
FILE_IO_ERROR = 1
INTERNAL_ERROR = 2
OPEN_ERROR = 3
TERMINATION_REQUESTED = 4
WRONG_ACCESS_TO_ARCHIVE = 5
OTHERS = 6.
IF SY-SUBRC <> C_0.
MESSAGE I001 WITH C_MSG4.
EXIT.
ENDIF.
ENDLOOP.
ENDFORM.
*& ---------------------------------------------------------*
*& Form WRITE_STATISTICS
*& ---------------------------------------------------------*
* Write Archive File statistics
*& ---------------------------------------------------------*
FORM WRITE_STATISTICS.
* create the default spool list
CALL FUNCTION 'ARCHIVE_WRITE_STATISTICS'
EXPORTING
ARCHIVE_HANDLE = V_HANDLE
EXCEPTIONS
INTERNAL_ERROR = 1
OTHERS = 2.
IF SY-SUBRC <> C_0.
MESSAGE I001 WITH C_MSG5.
EXIT.
ENDIF.
ENDFORM.
*& ---------------------------------------------------------*
*& Form CLOSE_ARCHIVE_FILE
*& -------------------------------------------------- *
* Close Archive File
*& ---------------------------------------------------------*
FORM CLOSE_ARCHIVE_FILE.
* close the archive session
CALL FUNCTION 'ARCHIVE_CLOSE_FILE'
EXPORTING
ARCHIVE_HANDLE = V_HANDLE
EXCEPTIONS
INTERNAL_ERROR = 1
WRONG_ACCESS_TO_ARCHIVE = 2
OTHERS = 3.
IF SY-SUBRC <> C_0.
MESSAGE I001 WITH C_MSG6.
EXIT.
ENDIF.
ENDFORM.
FORM GET_SELECTION_TEXTS.
V_NOFILE = C_NOFILE.
V_DTEST = C_DTEST.
V_DPROD = C_DPROD.
ENDFORM.
ABAP - Program To Get The Archiving Object Size
Description
/The report program computes the size of one or more archive objects by finding the size of individual tables that comprise the archive object. The output will be displayed on the screen and can also be downloaded to the presentation server./
REPORT Z_Compute_Archive_Object_Size.
TABLES : ARCH_OBJ.
TYPE-POOLS : ADK .
*---> data declaration
DATA : BEGIN OF I_TAB_AOBJ OCCURS 0,
OBJECT LIKE ARCH_OBJ-OBJECT.
DATA : END OF I_TAB_AOBJ.
DATA : BEGIN OF I_TAB_YES_DEL OCCURS 0,
OBJECT LIKE ARCH_OBJ-OBJECT,
TABNAME LIKE DD02V-TABNAME,
TEXT LIKE DD02V-DDTEXT.
DATA : END OF I_TAB_YES_DEL.
DATA: BEGIN OF I_DBSTAT OCCURS 0.
INCLUDE STRUCTURE DBSTATAM.
DATA: END OF I_DBSTAT.
DATA: BEGIN OF I_OUTPUT OCCURS 0,
OBJECT LIKE ARCH_OBJ-OBJECT,
TNAME LIKE I_DBSTAT-TNAME,
NROWS LIKE I_DBSTAT-NROWS,
OCCTB LIKE I_DBSTAT-OCCTB,
OCCIX LIKE I_DBSTAT-OCCIX.
DATA: END OF I_OUTPUT.
DATA: I_OBJECT_TABLES TYPE ADK_CCMS_TABLE OCCURS 0.
DATA: WA_OBJECT_TABLES TYPE ADK_CCMS_TABLE.
DATA: V_ARCOBJ LIKE ARCH_OBJ-OBJECT.
*---> selection criteria - archive object
SELECT-OPTIONS A_OBJECT FOR ARCH_OBJ-OBJECT.
*---> Output filename
PARAMETERS: FILENAME TYPE STRING.
*---> check the input
SELECT OBJECT INTO I_TAB_AOBJ FROM ARCH_OBJ WHERE OBJECT IN A_OBJECT.
APPEND I_TAB_AOBJ.
ENDSELECT.
*---> get the list of tables that comprise the arhive object
IF NOT I_TAB_AOBJ[] IS INITIAL.
REFRESH I_OBJECT_TABLES.
LOOP AT I_TAB_AOBJ.
CALL FUNCTION 'ADK_CCMS_GET_TABLES'
EXPORTING
OBJECT = I_TAB_AOBJ-OBJECT
DELETE_TABLES_ONLY = ''
TABLES
OBJECT_TABLES = I_OBJECT_TABLES
* EXCEPTIONS
* OBJECT_NOT_FOUND = 1
* OTHERS = 2
.
LOOP AT I_OBJECT_TABLES INTO WA_OBJECT_TABLES.
I_TAB_YES_DEL-OBJECT = I_TAB_AOBJ-OBJECT .
I_TAB_YES_DEL-TABNAME = WA_OBJECT_TABLES-TABNAME.
I_TAB_YES_DEL-TEXT = WA_OBJECT_TABLES-TEXT.
APPEND I_TAB_YES_DEL.
ENDLOOP.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDLOOP.
ENDIF.
*--> find size of each table that comprise the archive object
LOOP AT I_TAB_YES_DEL.
REFRESH I_DBSTAT.
MOVE I_TAB_YES_DEL-OBJECT TO V_ARCOBJ.
MOVE I_TAB_YES_DEL-TABNAME TO I_DBSTAT-TNAME.
APPEND I_DBSTAT.
CALL FUNCTION 'DB_TABLE_DATA_READ' " online lesen
TABLES
DBSTAT = I_DBSTAT
EXCEPTIONS
NO_DATA_FOUND = 2 " online nicht gefunden
OTHERS = 3.
I_OUTPUT-OBJECT = V_ARCOBJ.
LOOP AT I_DBSTAT.
I_OUTPUT-TNAME = I_DBSTAT-TNAME.
I_OUTPUT-NROWS = I_DBSTAT-NROWS.
I_OUTPUT-OCCTB = I_DBSTAT-OCCTB.
I_OUTPUT-OCCIX = I_DBSTAT-OCCIX.
APPEND I_OUTPUT.
ENDLOOP.
ENDLOOP.
*---> write output to screen
WRITE : 'OBJECT ', '', 'TABLE NAME ', '',
'Number of records ' , '' , 'Table Size(KB)' , '' , 'Indexes size (KB)'.
LOOP AT I_OUTPUT.
WRITE : / I_OUTPUT-OBJECT, '', I_OUTPUT-TNAME, '',
I_OUTPUT-NROWS , '' , I_OUTPUT-OCCTB , '' , I_OUTPUT-OCCIX.
ENDLOOP.
*---> write output to file
CALL METHOD CL_GUI_FRONTEND_SERVICES=>GUI_DOWNLOAD
EXPORTING
FILENAME = FILENAME
FILETYPE = 'DAT'
CHANGING
DATA_TAB = I_OUTPUT[]
EXCEPTIONS
FILE_WRITE_ERROR = 1
NO_BATCH = 2.
/The report program computes the size of one or more archive objects by finding the size of individual tables that comprise the archive object. The output will be displayed on the screen and can also be downloaded to the presentation server./
REPORT Z_Compute_Archive_Object_Size.
TABLES : ARCH_OBJ.
TYPE-POOLS : ADK .
*---> data declaration
DATA : BEGIN OF I_TAB_AOBJ OCCURS 0,
OBJECT LIKE ARCH_OBJ-OBJECT.
DATA : END OF I_TAB_AOBJ.
DATA : BEGIN OF I_TAB_YES_DEL OCCURS 0,
OBJECT LIKE ARCH_OBJ-OBJECT,
TABNAME LIKE DD02V-TABNAME,
TEXT LIKE DD02V-DDTEXT.
DATA : END OF I_TAB_YES_DEL.
DATA: BEGIN OF I_DBSTAT OCCURS 0.
INCLUDE STRUCTURE DBSTATAM.
DATA: END OF I_DBSTAT.
DATA: BEGIN OF I_OUTPUT OCCURS 0,
OBJECT LIKE ARCH_OBJ-OBJECT,
TNAME LIKE I_DBSTAT-TNAME,
NROWS LIKE I_DBSTAT-NROWS,
OCCTB LIKE I_DBSTAT-OCCTB,
OCCIX LIKE I_DBSTAT-OCCIX.
DATA: END OF I_OUTPUT.
DATA: I_OBJECT_TABLES TYPE ADK_CCMS_TABLE OCCURS 0.
DATA: WA_OBJECT_TABLES TYPE ADK_CCMS_TABLE.
DATA: V_ARCOBJ LIKE ARCH_OBJ-OBJECT.
*---> selection criteria - archive object
SELECT-OPTIONS A_OBJECT FOR ARCH_OBJ-OBJECT.
*---> Output filename
PARAMETERS: FILENAME TYPE STRING.
*---> check the input
SELECT OBJECT INTO I_TAB_AOBJ FROM ARCH_OBJ WHERE OBJECT IN A_OBJECT.
APPEND I_TAB_AOBJ.
ENDSELECT.
*---> get the list of tables that comprise the arhive object
IF NOT I_TAB_AOBJ[] IS INITIAL.
REFRESH I_OBJECT_TABLES.
LOOP AT I_TAB_AOBJ.
CALL FUNCTION 'ADK_CCMS_GET_TABLES'
EXPORTING
OBJECT = I_TAB_AOBJ-OBJECT
DELETE_TABLES_ONLY = ''
TABLES
OBJECT_TABLES = I_OBJECT_TABLES
* EXCEPTIONS
* OBJECT_NOT_FOUND = 1
* OTHERS = 2
.
LOOP AT I_OBJECT_TABLES INTO WA_OBJECT_TABLES.
I_TAB_YES_DEL-OBJECT = I_TAB_AOBJ-OBJECT .
I_TAB_YES_DEL-TABNAME = WA_OBJECT_TABLES-TABNAME.
I_TAB_YES_DEL-TEXT = WA_OBJECT_TABLES-TEXT.
APPEND I_TAB_YES_DEL.
ENDLOOP.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDLOOP.
ENDIF.
*--> find size of each table that comprise the archive object
LOOP AT I_TAB_YES_DEL.
REFRESH I_DBSTAT.
MOVE I_TAB_YES_DEL-OBJECT TO V_ARCOBJ.
MOVE I_TAB_YES_DEL-TABNAME TO I_DBSTAT-TNAME.
APPEND I_DBSTAT.
CALL FUNCTION 'DB_TABLE_DATA_READ' " online lesen
TABLES
DBSTAT = I_DBSTAT
EXCEPTIONS
NO_DATA_FOUND = 2 " online nicht gefunden
OTHERS = 3.
I_OUTPUT-OBJECT = V_ARCOBJ.
LOOP AT I_DBSTAT.
I_OUTPUT-TNAME = I_DBSTAT-TNAME.
I_OUTPUT-NROWS = I_DBSTAT-NROWS.
I_OUTPUT-OCCTB = I_DBSTAT-OCCTB.
I_OUTPUT-OCCIX = I_DBSTAT-OCCIX.
APPEND I_OUTPUT.
ENDLOOP.
ENDLOOP.
*---> write output to screen
WRITE : 'OBJECT ', '', 'TABLE NAME ', '',
'Number of records ' , '' , 'Table Size(KB)' , '' , 'Indexes size (KB)'.
LOOP AT I_OUTPUT.
WRITE : / I_OUTPUT-OBJECT, '', I_OUTPUT-TNAME, '',
I_OUTPUT-NROWS , '' , I_OUTPUT-OCCTB , '' , I_OUTPUT-OCCIX.
ENDLOOP.
*---> write output to file
CALL METHOD CL_GUI_FRONTEND_SERVICES=>GUI_DOWNLOAD
EXPORTING
FILENAME = FILENAME
FILETYPE = 'DAT'
CHANGING
DATA_TAB = I_OUTPUT[]
EXCEPTIONS
FILE_WRITE_ERROR = 1
NO_BATCH = 2.
ABAP - ALV Styles In A Fieldcatalogue.
*&---------------------------------------------------------------------*
*& Report ZALV_STYLES *
*& *
*&---------------------------------------------------------------------*
*& AS : ALV Styles in a fieldcatalogue. *
*& The ALV is developed using OOPS and various styles are given for *
*& each column in the fieldcatalogue *
*&---------------------------------------------------------------------*
REPORT zalv_styles.
*Include for ALV styles
INCLUDE cl_alv_control " use this include in <> symbol.
*Type ppols for alv
TYPE-POOLS : slis.
*structure for t582a tbale
TYPES : BEGIN OF ty_table,
infty TYPE infty,
pnnnn TYPE pnnnn_d,
zrmkz TYPE dzrmkz,
zeitb TYPE dzeitb,
dname TYPE dianm,
edynr TYPE edynp,
ldynr TYPE ldynp,
stypt TYPE stypt,
sytxt TYPE sytxt,
davo TYPE davo,
davoe TYPE davoe,
END OF ty_table.
*Structure for infotype text
TYPES : BEGIN OF ty_itext,
infty TYPE infty,
itext TYPE intxt,
sprsl TYPE sprsl,
END OF ty_itext.
*Structure for output display
TYPES : BEGIN OF ty_output,
infty TYPE infty,
itext TYPE intxt,
pnnnn TYPE pnnnn_d,
zrmkz TYPE dzrmkz,
zeitb TYPE dzeitb,
dname TYPE dianm,
edynr TYPE edynp,
ldynr TYPE ldynp,
stypt TYPE stypt,
sytxt TYPE sytxt,
davo TYPE davo,
davoe TYPE davoe,
text(6) TYPE c,
sradio(6) TYPE c,
scheck(6) TYPE c,
END OF ty_output.
*internal table and work area declarations
DATA : it_table TYPE STANDARD TABLE OF ty_table INITIAL SIZE 0,
it_output TYPE STANDARD TABLE OF ty_output INITIAL SIZE 0,
it_ittext TYPE STANDARD TABLE OF ty_itext INITIAL SIZE 0,
wa_table TYPE ty_table,
wa_output TYPE ty_output,
wa_ittext TYPE ty_itext.
*Data declarations for ALV
DATA: c_ccont TYPE REF TO cl_gui_custom_container, "Custom container object
c_alvgd TYPE REF TO cl_gui_alv_grid, "ALV grid object
it_fcat TYPE lvc_t_fcat, "Field catalogue
it_layout TYPE lvc_s_layo. "Layout
*Field symbols declarations for style
FIELD-SYMBOLS : TYPE lvc_s_fcat.
*initialization event
INITIALIZATION.
*start of selection event
START-OF-SELECTION.
*select the infotypes maintained
SELECT infty
pnnnn
zrmkz
zeitb
dname
edynr
ldynr
stypt
sytxt
davo
davoe
FROM t582a UP TO 25 ROWS
INTO CORRESPONDING FIELDS OF TABLE it_table.
* *Select the infotype texts
IF it_table[] IS NOT INITIAL.
SELECT itext
infty
sprsl
FROM t582s
INTO CORRESPONDING FIELDS OF TABLE it_ittext
FOR ALL ENTRIES IN it_table
WHERE infty = it_table-infty
AND sprsl = 'E'.
ENDIF.
*Apppending the data to the internal table of ALV output
LOOP AT it_table INTO wa_table.
wa_output-infty = wa_table-infty.
wa_output-pnnnn = wa_table-pnnnn.
wa_output-zrmkz = wa_table-zrmkz.
wa_output-zeitb = wa_table-zeitb.
wa_output-dname = wa_table-dname.
wa_output-edynr = wa_table-edynr.
wa_output-ldynr = wa_table-ldynr.
wa_output-stypt = wa_table-stypt.
wa_output-sytxt = wa_table-sytxt.
wa_output-davo = wa_table-davo.
wa_output-davoe = wa_table-davoe.
* For texts
READ TABLE it_ittext INTO wa_ittext WITH KEY infty = wa_table-infty.
wa_output-itext = wa_ittext-itext.
wa_output-text = wa_ittext-sprsl.
APPEND wa_output TO it_output.
CLEAR wa_output.
ENDLOOP.
* Calling the ALV screen with custom container
CALL SCREEN 0600.
*On this statement double click it takes you to the screen painter SE51.*Enter the attributes
*Create a Custom container and name it CC_CONT and OK code as OK_CODE.
*Save check and Activate the screen painter.
*Now a normal screen with number 600 is created which holds the ALV grid.* PBO of the actual screen ,
* Here we can give a title and customized menus
*&---------------------------------------------------------------------*
*& Module STATUS_0600 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE status_0600 OUTPUT.
* SET PF-STATUS 'xxxxxxxx'.
* SET TITLEBAR 'xxx'.
ENDMODULE. " STATUS_0600 OUTPUT
* calling the PBO module ALV_GRID.
*&---------------------------------------------------------------------*
*& Module ALV_GRID OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE alv_grid OUTPUT.
CREATE OBJECT c_ccont
EXPORTING
container_name = 'CC_CONT'.
CREATE OBJECT c_alvgd
EXPORTING
i_parent = c_ccont.
* SET field for ALV
PERFORM alv_build_fieldcat.
* Setting the styles for the ALV grid control
* using field-symbols
LOOP AT it_fcat ASSIGNING.
*For Each and every line of the fieldcat
CASE sy-tabix.
*Color Styles
*Background/Font/Group/positive/negative
WHEN '1'.
-style = alv_style_color_inv_positive.
WHEN '2'.
-style = alv_style_color_int_negative.
WHEN '3'.
-style = alv_style_color_inv_negative.
WHEN '4'.
-style = alv_style_color_int_positive.
WHEN '5'.
-style = alv_style_color_background.
-style = alv_style_color_inv_background.
WHEN '6'.
-style = alv_style_color_group.
-style = alv_style_color_int_background.
*Style for F4
WHEN '7'.
-style = alv_style_f4.
*Style for Alignment(others are also possible)
WHEN '8'.
-style = alv_style_align_left_bottom.
*Style for Font Underlined/Bold and Italic are possible
WHEN '9'.
-style = alv_style_font_underlined.
*Style for button type
WHEN '10'.
-style = alv_style_button.
*Style for Font Symbol
WHEN '11'.
-style = alv_style_font_symbol.
*Style for Radiobutton
WHEN '12'.
-style = alv_style_radio_checked.
*Style for checkbox
WHEN '13'.
-style = alv_style_checkbox_checked.
*Style for column style characteristics(highlighting the col)
WHEN '14'.
-style = alv_col_style_characteristic.
*Styles for Enabling the column
WHEN '15'.
-style = alv_style_enabled.
ENDCASE.
ENDLOOP.
* Set ALV attributes FOR LAYOUT
PERFORM alv_report_layout.
CHECK NOT c_alvgd IS INITIAL.
* Call ALV GRID
CALL METHOD c_alvgd->set_table_for_first_display
EXPORTING
is_layout = it_layout
CHANGING
it_outtab = it_output
it_fieldcatalog = it_fcat
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.
ENDMODULE. " ALV_GRID OUTPUT
*&---------------------------------------------------------------------*
*& Form alv_build_fieldcat
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* <--P_IT_FCAT text *----------------------------------------------------------------------* *subroutine to build fieldcat
FORM alv_build_fieldcat.
DATA lv_fldcat TYPE lvc_s_fcat. CLEAR lv_fldcat. lv_fldcat-row_pos = '1'. lv_fldcat-col_pos = '1'. lv_fldcat-fieldname = 'INFTY'.
ALSO READ:
- ALV Report With User Defined Buttons In It's Toolbar.
- ALV Report Program - Colors- Using REUSE_ALV_GRID_DISPLAY_LVC.
- Displaying Percentage In ALV List / Grid Display.
- Handling An ALV Grid With Check Box Using A Method.
..... Back To Index On ALV List/ Grid Display.
..... Back To MAIN INDEX.
*& Report ZALV_STYLES *
*& *
*&---------------------------------------------------------------------*
*& AS : ALV Styles in a fieldcatalogue. *
*& The ALV is developed using OOPS and various styles are given for *
*& each column in the fieldcatalogue *
*&---------------------------------------------------------------------*
REPORT zalv_styles.
*Include for ALV styles
INCLUDE cl_alv_control " use this include in <> symbol.
*Type ppols for alv
TYPE-POOLS : slis.
*structure for t582a tbale
TYPES : BEGIN OF ty_table,
infty TYPE infty,
pnnnn TYPE pnnnn_d,
zrmkz TYPE dzrmkz,
zeitb TYPE dzeitb,
dname TYPE dianm,
edynr TYPE edynp,
ldynr TYPE ldynp,
stypt TYPE stypt,
sytxt TYPE sytxt,
davo TYPE davo,
davoe TYPE davoe,
END OF ty_table.
*Structure for infotype text
TYPES : BEGIN OF ty_itext,
infty TYPE infty,
itext TYPE intxt,
sprsl TYPE sprsl,
END OF ty_itext.
*Structure for output display
TYPES : BEGIN OF ty_output,
infty TYPE infty,
itext TYPE intxt,
pnnnn TYPE pnnnn_d,
zrmkz TYPE dzrmkz,
zeitb TYPE dzeitb,
dname TYPE dianm,
edynr TYPE edynp,
ldynr TYPE ldynp,
stypt TYPE stypt,
sytxt TYPE sytxt,
davo TYPE davo,
davoe TYPE davoe,
text(6) TYPE c,
sradio(6) TYPE c,
scheck(6) TYPE c,
END OF ty_output.
*internal table and work area declarations
DATA : it_table TYPE STANDARD TABLE OF ty_table INITIAL SIZE 0,
it_output TYPE STANDARD TABLE OF ty_output INITIAL SIZE 0,
it_ittext TYPE STANDARD TABLE OF ty_itext INITIAL SIZE 0,
wa_table TYPE ty_table,
wa_output TYPE ty_output,
wa_ittext TYPE ty_itext.
*Data declarations for ALV
DATA: c_ccont TYPE REF TO cl_gui_custom_container, "Custom container object
c_alvgd TYPE REF TO cl_gui_alv_grid, "ALV grid object
it_fcat TYPE lvc_t_fcat, "Field catalogue
it_layout TYPE lvc_s_layo. "Layout
*Field symbols declarations for style
FIELD-SYMBOLS :
*initialization event
INITIALIZATION.
*start of selection event
START-OF-SELECTION.
*select the infotypes maintained
SELECT infty
pnnnn
zrmkz
zeitb
dname
edynr
ldynr
stypt
sytxt
davo
davoe
FROM t582a UP TO 25 ROWS
INTO CORRESPONDING FIELDS OF TABLE it_table.
* *Select the infotype texts
IF it_table[] IS NOT INITIAL.
SELECT itext
infty
sprsl
FROM t582s
INTO CORRESPONDING FIELDS OF TABLE it_ittext
FOR ALL ENTRIES IN it_table
WHERE infty = it_table-infty
AND sprsl = 'E'.
ENDIF.
*Apppending the data to the internal table of ALV output
LOOP AT it_table INTO wa_table.
wa_output-infty = wa_table-infty.
wa_output-pnnnn = wa_table-pnnnn.
wa_output-zrmkz = wa_table-zrmkz.
wa_output-zeitb = wa_table-zeitb.
wa_output-dname = wa_table-dname.
wa_output-edynr = wa_table-edynr.
wa_output-ldynr = wa_table-ldynr.
wa_output-stypt = wa_table-stypt.
wa_output-sytxt = wa_table-sytxt.
wa_output-davo = wa_table-davo.
wa_output-davoe = wa_table-davoe.
* For texts
READ TABLE it_ittext INTO wa_ittext WITH KEY infty = wa_table-infty.
wa_output-itext = wa_ittext-itext.
wa_output-text = wa_ittext-sprsl.
APPEND wa_output TO it_output.
CLEAR wa_output.
ENDLOOP.
* Calling the ALV screen with custom container
CALL SCREEN 0600.
*On this statement double click it takes you to the screen painter SE51.*Enter the attributes
*Create a Custom container and name it CC_CONT and OK code as OK_CODE.
*Save check and Activate the screen painter.
*Now a normal screen with number 600 is created which holds the ALV grid.* PBO of the actual screen ,
* Here we can give a title and customized menus
*&---------------------------------------------------------------------*
*& Module STATUS_0600 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE status_0600 OUTPUT.
* SET PF-STATUS 'xxxxxxxx'.
* SET TITLEBAR 'xxx'.
ENDMODULE. " STATUS_0600 OUTPUT
* calling the PBO module ALV_GRID.
*&---------------------------------------------------------------------*
*& Module ALV_GRID OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE alv_grid OUTPUT.
CREATE OBJECT c_ccont
EXPORTING
container_name = 'CC_CONT'.
CREATE OBJECT c_alvgd
EXPORTING
i_parent = c_ccont.
* SET field for ALV
PERFORM alv_build_fieldcat.
* Setting the styles for the ALV grid control
* using field-symbols
LOOP AT it_fcat ASSIGNING
*For Each and every line of the fieldcat
CASE sy-tabix.
*Color Styles
*Background/Font/Group/positive/negative
WHEN '1'.
WHEN '2'.
WHEN '3'.
WHEN '4'.
WHEN '5'.
WHEN '6'.
*Style for F4
WHEN '7'.
*Style for Alignment(others are also possible)
WHEN '8'.
*Style for Font Underlined/Bold and Italic are possible
WHEN '9'.
*Style for button type
WHEN '10'.
*Style for Font Symbol
WHEN '11'.
*Style for Radiobutton
WHEN '12'.
*Style for checkbox
WHEN '13'.
*Style for column style characteristics(highlighting the col)
WHEN '14'.
*Styles for Enabling the column
WHEN '15'.
ENDCASE.
ENDLOOP.
* Set ALV attributes FOR LAYOUT
PERFORM alv_report_layout.
CHECK NOT c_alvgd IS INITIAL.
* Call ALV GRID
CALL METHOD c_alvgd->set_table_for_first_display
EXPORTING
is_layout = it_layout
CHANGING
it_outtab = it_output
it_fieldcatalog = it_fcat
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.
ENDMODULE. " ALV_GRID OUTPUT
*&---------------------------------------------------------------------*
*& Form alv_build_fieldcat
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* <--P_IT_FCAT text *----------------------------------------------------------------------* *subroutine to build fieldcat
lv_fldcat-tabname = 'IT_OUTPUT'.
lv_fldcat-outputlen = 8.
lv_fldcat-scrtext_m = 'Infotype'.
lv_fldcat-icon = 'X'.
APPEND lv_fldcat TO it_fcat.
CLEAR lv_fldcat.
lv_fldcat-row_pos = '1'.
lv_fldcat-col_pos = '2'.
lv_fldcat-fieldname = 'PNNNN'.
lv_fldcat-tabname = 'IT_OUTPUT'.
lv_fldcat-outputlen = 15.
lv_fldcat-scrtext_m = 'Structure'.
lv_fldcat-icon = ''.
APPEND lv_fldcat TO it_fcat.
CLEAR lv_fldcat.
lv_fldcat-row_pos = '1'.
lv_fldcat-col_pos = '3'.
lv_fldcat-fieldname = 'ITEXT'.
lv_fldcat-tabname = 'IT_OUTPUT'.
lv_fldcat-outputlen = 60.
lv_fldcat-scrtext_m = 'Description'.
lv_fldcat-icon = ''.
APPEND lv_fldcat TO it_fcat.
CLEAR lv_fldcat.
lv_fldcat-row_pos = '1'.
lv_fldcat-col_pos = '4'.
lv_fldcat-fieldname = 'TEXT'.
lv_fldcat-tabname = 'IT_OUTPUT'.
lv_fldcat-outputlen = 5.
lv_fldcat-scrtext_m = 'General'.
lv_fldcat-icon = ''.
APPEND lv_fldcat TO it_fcat.
CLEAR lv_fldcat.
lv_fldcat-row_pos = '1'.
lv_fldcat-col_pos = '5'.
lv_fldcat-fieldname = 'ZRMKZ'.
lv_fldcat-tabname = 'IT_OUTPUT'.
lv_fldcat-outputlen = 1.
lv_fldcat-scrtext_m = 'PERIOD'.
lv_fldcat-icon = ''.
APPEND lv_fldcat TO it_fcat.
CLEAR lv_fldcat.
lv_fldcat-row_pos = '1'.
lv_fldcat-col_pos = '6'.
lv_fldcat-fieldname = 'ZEITB'.
lv_fldcat-tabname = 'IT_OUTPUT'.
lv_fldcat-outputlen = 60.
lv_fldcat-scrtext_m = 'Time constraint'.
lv_fldcat-icon = ''.
APPEND lv_fldcat TO it_fcat.
CLEAR lv_fldcat.
lv_fldcat-row_pos = '1'.
lv_fldcat-col_pos = '7'.
lv_fldcat-fieldname = 'DNAME'.
lv_fldcat-tabname = 'IT_OUTPUT'.
lv_fldcat-outputlen = 15.
lv_fldcat-scrtext_m = 'Dialogmodule'.
lv_fldcat-icon = ''.
APPEND lv_fldcat TO it_fcat.
CLEAR lv_fldcat.
lv_fldcat-row_pos = '1'.
lv_fldcat-col_pos = '8'.
lv_fldcat-fieldname = 'EDYNR'.
lv_fldcat-tabname = 'IT_OUTPUT'.
lv_fldcat-outputlen = 10.
lv_fldcat-scrtext_m = 'Single screenno'.
lv_fldcat-icon = ''.
APPEND lv_fldcat TO it_fcat.
CLEAR lv_fldcat.
lv_fldcat-row_pos = '1'.
lv_fldcat-col_pos = '9'.
lv_fldcat-fieldname = 'LDYNR'.
lv_fldcat-tabname = 'IT_OUTPUT'.
lv_fldcat-outputlen = 10.
lv_fldcat-scrtext_m = 'List screenno'.
lv_fldcat-icon = ''.
APPEND lv_fldcat TO it_fcat.
CLEAR lv_fldcat.
lv_fldcat-row_pos = '1'.
lv_fldcat-col_pos = '10'.
lv_fldcat-fieldname = 'STYPT'.
lv_fldcat-tabname = 'IT_OUTPUT'.
lv_fldcat-outputlen = 10.
lv_fldcat-scrtext_m = 'SubtypeTable'.
lv_fldcat-icon = ''.
APPEND lv_fldcat TO it_fcat.
CLEAR lv_fldcat.
lv_fldcat-row_pos = '1'.
lv_fldcat-col_pos = '11'.
lv_fldcat-fieldname = 'SYTXT'.
lv_fldcat-tabname = 'IT_OUTPUT'.
lv_fldcat-outputlen = 10.
lv_fldcat-scrtext_m = 'Font Symbol'.
lv_fldcat-icon = ''.
APPEND lv_fldcat TO it_fcat.
CLEAR lv_fldcat.
lv_fldcat-row_pos = '1'.
lv_fldcat-col_pos = '12'.
lv_fldcat-fieldname = 'SRADIO'.
lv_fldcat-tabname = 'IT_OUTPUT'.
lv_fldcat-outputlen = 10.
lv_fldcat-scrtext_m = 'RADIO'.
lv_fldcat-icon = ''.
APPEND lv_fldcat TO it_fcat.
CLEAR lv_fldcat.
lv_fldcat-row_pos = '1'.
lv_fldcat-col_pos = '13'.
lv_fldcat-fieldname = 'SCHECK'.
lv_fldcat-tabname = 'IT_OUTPUT'.
lv_fldcat-outputlen = 10.
lv_fldcat-scrtext_m = 'CHECK'.
lv_fldcat-icon = ''.
APPEND lv_fldcat TO it_fcat.
CLEAR lv_fldcat.
lv_fldcat-row_pos = '1'.
lv_fldcat-col_pos = '14'.
lv_fldcat-fieldname = 'DAVO'.
lv_fldcat-tabname = 'IT_OUTPUT'.
lv_fldcat-outputlen = 10.
lv_fldcat-scrtext_m = 'Start Date'.
lv_fldcat-icon = ''.
APPEND lv_fldcat TO it_fcat.
CLEAR lv_fldcat.
lv_fldcat-row_pos = '1'.
lv_fldcat-col_pos = '15'.
lv_fldcat-fieldname = 'DAVOE'.
lv_fldcat-tabname = 'IT_OUTPUT'.
lv_fldcat-outputlen = 10.
lv_fldcat-scrtext_m = 'End date'.
lv_fldcat-icon = ''.
APPEND lv_fldcat TO it_fcat.
CLEAR lv_fldcat.
ENDFORM. " alv_build_fieldcat
*&---------------------------------------------------------------------*
*& Form alv_report_layout *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * <--P_IT_LAYOUT text *----------------------------------------------------------------------* *Subroutine for setting alv layout
FORM alv_report_layout.
it_layout-cwidth_opt = 'X'.
it_layout-zebra = 'X'.
it_layout-col_opt = 'X'.
ENDFORM. " alv_report_layout
* PAI module of the screen created. In case we use an interactive ALV or
*for additional functionalities we can create OK codes
*and based on the user command we can do the coding.
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_0600 INPUT *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------*
MODULE user_command_0600 INPUT.
ENDMODULE. " USER_COMMAND_0600 INPUT
ALSO READ:
- ALV Report With User Defined Buttons In It's Toolbar.
- ALV Report Program - Colors- Using REUSE_ALV_GRID_DISPLAY_LVC.
- Displaying Percentage In ALV List / Grid Display.
- Handling An ALV Grid With Check Box Using A Method.
..... Back To Index On ALV List/ Grid Display.
..... Back To MAIN INDEX.
ABAP - F4 (Value On Request) For Field Using FM RSISP_DDIC_F4_VALUES.
REPORT zdaomain.
data: values like DDSHRETVAL occurs 0 with header line .
CALL FUNCTION 'RSISP_DDIC_F4_VALUES'
EXPORTING
tabname = 'PA0002'
fieldname = 'PERNR'
TABLES
VALUES = VALUES.
LOOP AT VALUES .
WRITE:/ VALUES-RECORDPOS ,
VALUES-FIELDVAL .
ENDLOOP .
ALSO READ:
- F4 (Value On Request) For Organization Unit In HR Report Program.
- F4 (Value On Request) For Organization Unit In HR Report Program.
- Select Input Only Through F4 (Value On Request).
- Selection Screen With Radio Buttons.
- Selection Screen With Push Buttons.
- Selection Screen Events.
- Selection Screen With Push Buttons With Events.
- Display LOGO On Selection Screen.
- Selection Screen Listbox From Table Entries.
data: values like DDSHRETVAL occurs 0 with header line .
CALL FUNCTION 'RSISP_DDIC_F4_VALUES'
EXPORTING
tabname = 'PA0002'
fieldname = 'PERNR'
TABLES
VALUES = VALUES.
LOOP AT VALUES .
WRITE:/ VALUES-RECORDPOS ,
VALUES-FIELDVAL .
ENDLOOP .
ALSO READ:
- F4 (Value On Request) For Organization Unit In HR Report Program.
- F4 (Value On Request) For Organization Unit In HR Report Program.
- Select Input Only Through F4 (Value On Request).
- Selection Screen With Radio Buttons.
- Selection Screen With Push Buttons.
- Selection Screen Events.
- Selection Screen With Push Buttons With Events.
- Display LOGO On Selection Screen.
- Selection Screen Listbox From Table Entries.
ABAP - Sample Program To Get All The Tables Of A T-Code.
REPORT ZPOO_FIND_TABLE2 NO STANDARD PAGE HEADING.
*&---------------------------------------------------------------------*
** TITLE: Program to get all the tables of a TCode
***************************** DECLARATIONS **************************
TABLES : TSTC, tstct.
TABLES : DD03l, DD02l.
DATA : Program like sy-repid.
DATA : BEGIN OF I_FINAL OCCURS 0,
tabname LIKE dd02l-tabname,
TABCLASS LIKE dd02l-tabCLASS,
TEXT LIKE DD02T-DDTEXT,
END OF I_FINAL.
DATA : BEGIN of ITAB Occurs 0,
name like dd02l-tabname,
END OF ITAB.
DATA : TCD(100) TYPE C.
DATA : var1 LIKE dd02l-tabname.
DATA : DESC LIKE TSTCT-TTEXT.
****************************** SELECTION SCREEN ************************
selection-screen skip.
SELECTION-SCREEN : BEGIN OF BLOCK b2 WITH FRAME TITLE text-002.
PARAMETERS : r1 RADIOBUTTON GROUP r DEFAULT 'X'.
Parameters : Tcode like sy-tcode.
selection-screen skip.
PARAMETERS : r2 RADIOBUTTON GROUP r.
Parameters : Prog like sy-repid.
SELECTION-SCREEN END OF BLOCK b2.
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE text-001.
select-options : Type for dd02l-tabclass .
SELECTION-SCREEN END OF BLOCK B1 .
****************************** AT SELECTION SCREEN **********************
at selection-screen.
if r1 = 'X' and Tcode is initial.
message e001(00) with 'Enter Transaction Code' .
elseif r2 = 'X' and Prog is initial.
message e001(00) with 'Enter Program Name' .
endif.
****************************** START OF SELECTION **********************
START-OF-SELECTION.
if r1 = 'X'.
Prog = ' '.
select single * from TSTC where tcode = tcode.
if sy-subrc = 0.
program = TSTC-PGMNA.
select single TTEXT from tstct into desc where tcode = tcode and SPRSL = 'E'.
else.
Write :/ 'Invalid Transaction Code'.
exit.
endif.
elseif r2 = 'X'.
Tcode = ' '.
program = Prog.
endif.
CALL FUNCTION 'GET_TABLES'
EXPORTING
PROGNAME = Program
TABLES
TABLES_TAB = itab.
if itab is initial.
skip.
skip.
skip.
skip.
skip.
WRITE :/40 'No Data Found' color 6 INTENSIFIED OFF.
ELSE.
PERFORM : categorize.
endif.
************************** END OF SELECTION ********************************
END-OF-SELECTION.
LOOP AT I_FINAL.
WRITE :/4 I_FINAL-tabname COLOR 2 INTENSIFIED OFF NO-GAP HOTSPOT ON, 35 I_FINAL-TABCLASS COLOR 2 INTENSIFIED OFF NO-GAP,
50 I_FINAL-TEXT COLOR 2 INTENSIFIED OFF NO-GAP.
ENDLOOP.
************************** AT LINE SELECTION ********************************
AT LINE-SELECTION.
TCD = SY-LISEL.
var1 = TCD+3(30).
set parameter id 'DTB' FIELD VAR1.
call transaction 'SE11' and skip first screen.
************************** TOP OF PAGE ********************************
TOP-OF-PAGE.
WRITE :/45 'TABLE DETAILS RELATED TO THE TRANSACTION CODE' COLOR 7 .
WRITE :/2 'DATE : ' COLOR 1, SY-DATUM COLOR 1 INTENSIFIED OFF NO-GAP.
WRITE :/2 'TRANSACTION CODE : ' COLOR 1, Tcode COLOR 1 INTENSIFIED OFF NO-GAP.
WRITE :/2 'TCODE DESCRIPTION : ' COLOR 1, desc COLOR 1 INTENSIFIED OFF NO-GAP.
WRITE :/2 'PROGRAM NAME : ' COLOR 1, PROGRAM COLOR 1 INTENSIFIED OFF NO-GAP.
SKIP 1.
WRITE :/1(140) SY-ULINE.
WRITE :/4 'TABLE NAME' COLOR 5 INTENSIFIED OFF NO-GAP,35 'TABLE TYPE' COLOR 5 INTENSIFIED OFF NO-GAP,
55 'DESCRIPTION' COLOR 5 INTENSIFIED OFF NO-GAP.
WRITE :/1(140) SY-ULINE.
.
*&---------------------------------------------------------------------*
*& Form categorize
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text *----------------------------------------------------------------------* FORM categorize . SELECT dd02l~tabname dd02l~tabCLASS DD02T~DDTEXT FROM dd02l INNER JOIN DD02T ON dd02l~tabname = dd02T~tabname INTO TABLE I_FINAL FOR ALL ENTRIES IN itab WHERE DD02L~TABNAME = ITAB-NAME AND TABCLASS IN TYPE AND DDLANGUAGE = 'E'. if sy-subrc <> 0.
skip.
skip.
skip.
skip.
skip.
WRITE :/40 'No Data Found' color 6 INTENSIFIED OFF.
endif.
ENDFORM. " categorize
*&---------------------------------------------------------------------*
** TITLE: Program to get all the tables of a TCode
***************************** DECLARATIONS **************************
TABLES : TSTC, tstct.
TABLES : DD03l, DD02l.
DATA : Program like sy-repid.
DATA : BEGIN OF I_FINAL OCCURS 0,
tabname LIKE dd02l-tabname,
TABCLASS LIKE dd02l-tabCLASS,
TEXT LIKE DD02T-DDTEXT,
END OF I_FINAL.
DATA : BEGIN of ITAB Occurs 0,
name like dd02l-tabname,
END OF ITAB.
DATA : TCD(100) TYPE C.
DATA : var1 LIKE dd02l-tabname.
DATA : DESC LIKE TSTCT-TTEXT.
****************************** SELECTION SCREEN ************************
selection-screen skip.
SELECTION-SCREEN : BEGIN OF BLOCK b2 WITH FRAME TITLE text-002.
PARAMETERS : r1 RADIOBUTTON GROUP r DEFAULT 'X'.
Parameters : Tcode like sy-tcode.
selection-screen skip.
PARAMETERS : r2 RADIOBUTTON GROUP r.
Parameters : Prog like sy-repid.
SELECTION-SCREEN END OF BLOCK b2.
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE text-001.
select-options : Type for dd02l-tabclass .
SELECTION-SCREEN END OF BLOCK B1 .
****************************** AT SELECTION SCREEN **********************
at selection-screen.
if r1 = 'X' and Tcode is initial.
message e001(00) with 'Enter Transaction Code' .
elseif r2 = 'X' and Prog is initial.
message e001(00) with 'Enter Program Name' .
endif.
****************************** START OF SELECTION **********************
START-OF-SELECTION.
if r1 = 'X'.
Prog = ' '.
select single * from TSTC where tcode = tcode.
if sy-subrc = 0.
program = TSTC-PGMNA.
select single TTEXT from tstct into desc where tcode = tcode and SPRSL = 'E'.
else.
Write :/ 'Invalid Transaction Code'.
exit.
endif.
elseif r2 = 'X'.
Tcode = ' '.
program = Prog.
endif.
CALL FUNCTION 'GET_TABLES'
EXPORTING
PROGNAME = Program
TABLES
TABLES_TAB = itab.
if itab is initial.
skip.
skip.
skip.
skip.
skip.
WRITE :/40 'No Data Found' color 6 INTENSIFIED OFF.
ELSE.
PERFORM : categorize.
endif.
************************** END OF SELECTION ********************************
END-OF-SELECTION.
LOOP AT I_FINAL.
WRITE :/4 I_FINAL-tabname COLOR 2 INTENSIFIED OFF NO-GAP HOTSPOT ON, 35 I_FINAL-TABCLASS COLOR 2 INTENSIFIED OFF NO-GAP,
50 I_FINAL-TEXT COLOR 2 INTENSIFIED OFF NO-GAP.
ENDLOOP.
************************** AT LINE SELECTION ********************************
AT LINE-SELECTION.
TCD = SY-LISEL.
var1 = TCD+3(30).
set parameter id 'DTB' FIELD VAR1.
call transaction 'SE11' and skip first screen.
************************** TOP OF PAGE ********************************
TOP-OF-PAGE.
WRITE :/45 'TABLE DETAILS RELATED TO THE TRANSACTION CODE' COLOR 7 .
WRITE :/2 'DATE : ' COLOR 1, SY-DATUM COLOR 1 INTENSIFIED OFF NO-GAP.
WRITE :/2 'TRANSACTION CODE : ' COLOR 1, Tcode COLOR 1 INTENSIFIED OFF NO-GAP.
WRITE :/2 'TCODE DESCRIPTION : ' COLOR 1, desc COLOR 1 INTENSIFIED OFF NO-GAP.
WRITE :/2 'PROGRAM NAME : ' COLOR 1, PROGRAM COLOR 1 INTENSIFIED OFF NO-GAP.
SKIP 1.
WRITE :/1(140) SY-ULINE.
WRITE :/4 'TABLE NAME' COLOR 5 INTENSIFIED OFF NO-GAP,35 'TABLE TYPE' COLOR 5 INTENSIFIED OFF NO-GAP,
55 'DESCRIPTION' COLOR 5 INTENSIFIED OFF NO-GAP.
WRITE :/1(140) SY-ULINE.
.
*&---------------------------------------------------------------------*
*& Form categorize
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text *----------------------------------------------------------------------* FORM categorize . SELECT dd02l~tabname dd02l~tabCLASS DD02T~DDTEXT FROM dd02l INNER JOIN DD02T ON dd02l~tabname = dd02T~tabname INTO TABLE I_FINAL FOR ALL ENTRIES IN itab WHERE DD02L~TABNAME = ITAB-NAME AND TABCLASS IN TYPE AND DDLANGUAGE = 'E'. if sy-subrc <> 0.
skip.
skip.
skip.
skip.
skip.
WRITE :/40 'No Data Found' color 6 INTENSIFIED OFF.
endif.
ENDFORM. " categorize
ABAP - Convert List Report Output Into PDF Format.
&---------------------------------------------------------------------
*& Report Z_CREATE_PDF_ABAPLIST
&---------------------------------------------------------------------
*& Description: Simple Program to generate PDF from ABAP List Output
&---------------------------------------------------------------------
*& Report Z_CREATE_PDF_ABAPLIST
&---------------------------------------------------------------------
*& Description: Simple Program to generate PDF from ABAP List Output
&---------------------------------------------------------------------
REPORT Z_CREATE_PDF_ABAPLIST NO STANDARD PAGE HEADING.
* PF-status containing a PDF button in the report Output to generate
* PDF form
SET PF-STATUS 'Z_PDF'.
----------------------------------------------------------------------
*Table Declarations
----------------------------------------------------------------------
TABLES: MARA, MARC, MAKT.
---------------------------------------------------------------------
* Internal Table Declarations
----------------------------------------------------------------------
DATA: BEGIN OF TS_MARA OCCURS 0,
MATNR LIKE MARA-MATNR,
MTART LIKE MARA-MTART,
MATKL LIKE MARA-MATKL,
LVORM LIKE MARA-LVORM,
WERKS LIKE MARC-WERKS,
MAKTX LIKE MAKT-MAKTX,
END OF TS_MARA.
----------------------------------------------------------------------
* Selection Screen Parameters
----------------------------------------------------------------------
SELECTION-SCREEN BEGIN OF BLOCK B1.
SELECT-OPTIONS: S_MATNR FOR MARA-MATNR OBLIGATORY,
S_WERKS FOR MARC-WERKS OBLIGATORY.
SELECTION-SCREEN END OF BLOCK B1.
----------------------------------------------------------------------
TOP-OF-PAGE.
----------------------------------------------------------------------
write: 40 'Generating PDF from List Output' color 1 intensified on.
skip 1.
write: /1 'Date :', SY-DATUM,
/1 'User ID :', SY-UNAME,
/1(112) SY-ULINE.
----------------------------------------------------------------------
START-OF-SELECTION.
----------------------------------------------------------------------
* Perform for Basic Selection
PERFORM GET_MARA.
* Perform to Display Data
PERFORM DISPLAY_MARA.
----------------------------------------------------------------------------------
AT USER-COMMAND.
----------------------------------------------------------------------------------
* User Command to generate PDF Form
AT USER-COMMAND.
CASE SY-UCOMM.
WHEN 'PDF'.
DATA: L_PARAMS TYPE PRI_PARAMS,
L_VALID TYPE STRING,
W_SPOOL_NR LIKE TSP01-RQIDENT.
* TO GET PRINT PARAMETERS
CALL FUNCTION 'GET_PRINT_PARAMETERS'
IMPORTING
OUT_PARAMETERS = L_PARAMS
VALID = L_VALID.
IF SY-SUBRC <> 0.
ENDIF.
* Internal table for Selection Screen
DATA: BEGIN OF I_RSPARAMS OCCURS 0.
INCLUDE STRUCTURE RSPARAMS.
DATA: END OF I_RSPARAMS.
* Store the current selection screen details
CALL FUNCTION 'RS_REFRESH_FROM_SELECTOPTIONS'
EXPORTING
CURR_REPORT = SY-REPID
* IMPORTING
* SP =
TABLES
SELECTION_TABLE = I_RSPARAMS
* EXCEPTIONS
* NOT_FOUND = 1
* NO_REPORT = 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.
* SUBMIT TO GET THE SPOOL NUMBER
SUBMIT Z_CREATE_PDF_ABAPLIST WITH SELECTION-TABLE I_RSPARAMS
TO SAP-SPOOL
SPOOL PARAMETERS L_PARAMS
WITHOUT SPOOL DYNPRO
AND RETURN.
* SELECT THE RECENTLY CREATED SPOOL
SELECT MAX( RQIDENT ) INTO W_SPOOL_NR FROM TSP01
WHERE RQCLIENT = SY-MANDT
AND RQOWNER = SY-UNAME.
*REPORT TO GENERATE SPOOL NUMBER FOR PDF CONVERT
SUBMIT RSTXPDF5 WITH SPOOLNO = W_SPOOL_NR
WITH DSTDEVIC = 'LOCL' AND RETURN .
IF SY-SUBRC EQ 0.
CLEAR W_SPOOL_NR.
* SELECT THE RECENTLY CREATED SPOOL FOR PDF
SELECT MAX( RQIDENT ) INTO W_SPOOL_NR FROM TSP01
WHERE RQCLIENT = SY-MANDT
AND RQOWNER = SY-UNAME.
*REPORT TO DOWNLOAD PDF SPOOL TO GUI
SUBMIT RSTXPDFT5 WITH SPOOLID = W_SPOOL_NR
AND RETURN.
ENDIF.
ENDCASE.
&---------------------------------------------------------------------
*& Form GET_MARA
&---------------------------------------------------------------------
* text
----------------------------------------------------------------------
* --> p1 text
* <-- p2 text ---------------------------------------------------------------------- FORM GET_MARA . CLEAR : TS_MARA. REFRESH: TS_MARA. * To select Materials based on Selection Criteria SELECT A~MATNR A~MTART A~MATKL A~LVORM B~WERKS INTO CORRESPONDING FIELDS OF TABLE TS_MARA FROM MARA AS A INNER JOIN MARC AS B ON A~MATNR EQ B~MATNR WHERE A~MATNR IN S_MATNR AND B~WERKS IN S_WERKS. LOOP AT TS_MARA. SELECT SINGLE * FROM MAKT WHERE MATNR EQ TS_MARA-MATNR AND SPRAS EQ SY-LANGU. MOVE MAKT-MAKTX TO TS_MARA-MAKTX. MODIFY TS_MARA INDEX SY-TABIX. ENDLOOP. ENDFORM. " GET_MARA &--------------------------------------------------------------------- *& Form DISPLAY_MARA &--------------------------------------------------------------------- * text ---------------------------------------------------------------------- * --> p1 text
* <-- p2 text ---------------------------------------------------------------------- FORM DISPLAY_MARA . CLEAR : TS_MARA. WRITE: /1 '|', 2(18) 'Material Number' COLOR 7, 21 '|', 22(5) 'Plant ' COLOR 7, 28 '|', 29(13) 'Material Type ' COLOR 7, 42 '|', 43(14) 'Material Group ' COLOR 7, 57 '|', 58(13) 'Deletion Flag ' COLOR 7, 71 '|', 72(40) 'Description ' COLOR 7, 112 '|'. WRITE: /1(112) SY-ULINE. LOOP AT TS_MARA. WRITE: /1 '|', 2(18) TS_MARA-MATNR, 21 '|', 22(5) TS_MARA-WERKS, 28 '|', 29(13) TS_MARA-MTART, 42 '|', 43(14) TS_MARA-MATKL, 57 '|', 58(13) TS_MARA-LVORM, 71 '|', 72(40) TS_MARA-MAKTX, 112 '|'. WRITE: /1(112) SY-ULINE. ENDLOOP. ENDFORM. " DISPLAY_MARA
* PF-status containing a PDF button in the report Output to generate
* PDF form
SET PF-STATUS 'Z_PDF'.
----------------------------------------------------------------------
*Table Declarations
----------------------------------------------------------------------
TABLES: MARA, MARC, MAKT.
---------------------------------------------------------------------
* Internal Table Declarations
----------------------------------------------------------------------
DATA: BEGIN OF TS_MARA OCCURS 0,
MATNR LIKE MARA-MATNR,
MTART LIKE MARA-MTART,
MATKL LIKE MARA-MATKL,
LVORM LIKE MARA-LVORM,
WERKS LIKE MARC-WERKS,
MAKTX LIKE MAKT-MAKTX,
END OF TS_MARA.
----------------------------------------------------------------------
* Selection Screen Parameters
----------------------------------------------------------------------
SELECTION-SCREEN BEGIN OF BLOCK B1.
SELECT-OPTIONS: S_MATNR FOR MARA-MATNR OBLIGATORY,
S_WERKS FOR MARC-WERKS OBLIGATORY.
SELECTION-SCREEN END OF BLOCK B1.
----------------------------------------------------------------------
TOP-OF-PAGE.
----------------------------------------------------------------------
write: 40 'Generating PDF from List Output' color 1 intensified on.
skip 1.
write: /1 'Date :', SY-DATUM,
/1 'User ID :', SY-UNAME,
/1(112) SY-ULINE.
----------------------------------------------------------------------
START-OF-SELECTION.
----------------------------------------------------------------------
* Perform for Basic Selection
PERFORM GET_MARA.
* Perform to Display Data
PERFORM DISPLAY_MARA.
----------------------------------------------------------------------------------
AT USER-COMMAND.
----------------------------------------------------------------------------------
* User Command to generate PDF Form
AT USER-COMMAND.
CASE SY-UCOMM.
WHEN 'PDF'.
DATA: L_PARAMS TYPE PRI_PARAMS,
L_VALID TYPE STRING,
W_SPOOL_NR LIKE TSP01-RQIDENT.
* TO GET PRINT PARAMETERS
CALL FUNCTION 'GET_PRINT_PARAMETERS'
IMPORTING
OUT_PARAMETERS = L_PARAMS
VALID = L_VALID.
IF SY-SUBRC <> 0.
ENDIF.
* Internal table for Selection Screen
DATA: BEGIN OF I_RSPARAMS OCCURS 0.
INCLUDE STRUCTURE RSPARAMS.
DATA: END OF I_RSPARAMS.
* Store the current selection screen details
CALL FUNCTION 'RS_REFRESH_FROM_SELECTOPTIONS'
EXPORTING
CURR_REPORT = SY-REPID
* IMPORTING
* SP =
TABLES
SELECTION_TABLE = I_RSPARAMS
* EXCEPTIONS
* NOT_FOUND = 1
* NO_REPORT = 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.
* SUBMIT TO GET THE SPOOL NUMBER
SUBMIT Z_CREATE_PDF_ABAPLIST WITH SELECTION-TABLE I_RSPARAMS
TO SAP-SPOOL
SPOOL PARAMETERS L_PARAMS
WITHOUT SPOOL DYNPRO
AND RETURN.
* SELECT THE RECENTLY CREATED SPOOL
SELECT MAX( RQIDENT ) INTO W_SPOOL_NR FROM TSP01
WHERE RQCLIENT = SY-MANDT
AND RQOWNER = SY-UNAME.
*REPORT TO GENERATE SPOOL NUMBER FOR PDF CONVERT
SUBMIT RSTXPDF5 WITH SPOOLNO = W_SPOOL_NR
WITH DSTDEVIC = 'LOCL' AND RETURN .
IF SY-SUBRC EQ 0.
CLEAR W_SPOOL_NR.
* SELECT THE RECENTLY CREATED SPOOL FOR PDF
SELECT MAX( RQIDENT ) INTO W_SPOOL_NR FROM TSP01
WHERE RQCLIENT = SY-MANDT
AND RQOWNER = SY-UNAME.
*REPORT TO DOWNLOAD PDF SPOOL TO GUI
SUBMIT RSTXPDFT5 WITH SPOOLID = W_SPOOL_NR
AND RETURN.
ENDIF.
ENDCASE.
&---------------------------------------------------------------------
*& Form GET_MARA
&---------------------------------------------------------------------
* text
----------------------------------------------------------------------
* --> p1 text
* <-- p2 text ---------------------------------------------------------------------- FORM GET_MARA . CLEAR : TS_MARA. REFRESH: TS_MARA. * To select Materials based on Selection Criteria SELECT A~MATNR A~MTART A~MATKL A~LVORM B~WERKS INTO CORRESPONDING FIELDS OF TABLE TS_MARA FROM MARA AS A INNER JOIN MARC AS B ON A~MATNR EQ B~MATNR WHERE A~MATNR IN S_MATNR AND B~WERKS IN S_WERKS. LOOP AT TS_MARA. SELECT SINGLE * FROM MAKT WHERE MATNR EQ TS_MARA-MATNR AND SPRAS EQ SY-LANGU. MOVE MAKT-MAKTX TO TS_MARA-MAKTX. MODIFY TS_MARA INDEX SY-TABIX. ENDLOOP. ENDFORM. " GET_MARA &--------------------------------------------------------------------- *& Form DISPLAY_MARA &--------------------------------------------------------------------- * text ---------------------------------------------------------------------- * --> p1 text
* <-- p2 text ---------------------------------------------------------------------- FORM DISPLAY_MARA . CLEAR : TS_MARA. WRITE: /1 '|', 2(18) 'Material Number' COLOR 7, 21 '|', 22(5) 'Plant ' COLOR 7, 28 '|', 29(13) 'Material Type ' COLOR 7, 42 '|', 43(14) 'Material Group ' COLOR 7, 57 '|', 58(13) 'Deletion Flag ' COLOR 7, 71 '|', 72(40) 'Description ' COLOR 7, 112 '|'. WRITE: /1(112) SY-ULINE. LOOP AT TS_MARA. WRITE: /1 '|', 2(18) TS_MARA-MATNR, 21 '|', 22(5) TS_MARA-WERKS, 28 '|', 29(13) TS_MARA-MTART, 42 '|', 43(14) TS_MARA-MATKL, 57 '|', 58(13) TS_MARA-LVORM, 71 '|', 72(40) TS_MARA-MAKTX, 112 '|'. WRITE: /1(112) SY-ULINE. ENDLOOP. ENDFORM. " DISPLAY_MARA
ALSO READ:
- Creating A Directory On Presentation Server Using FM GUI_CREATE_DIRECTORY.
- Removing A Directory From Presentation Server Using FM GUI_REMOVE_DIRECTORY.
- Removing A File From Presentation Server Using FM GUI_DELETE_FILE.
- ZIP Files In Application Server Using FM SCMS_XSTRING_TO_BINARY.
- Saving Files To Presentation Server Using Methods.
RETURN TO MAIN INDEX:
- Sample Programs On Uploading & Downloading Files.
- Sample Programs On HR ABAP.
- Sample Report Programs On ALV List/ Grid Display.
- Sample Programs On Selection Screen.
- Sample Programs On BDC.
.....Back To MAIN INDEX.
ABAP - General Processs For Working With Files.
some general process of working with files when ABAP programmming. Such as,Uploading/Downloading files from/to Application/Presentation server, adding F4 help to file path on the selection-screen,checking file existence.
Check File Existence
Before we process the file which is input on the selection screen by end-user, we need to check whether this file exists or not. If it does not exist, we just give an error message and need not to go into the main program .This logic should be done within the event 'AT SELECTION-SCREEN'.
presentation server file
For the presentation server file,here intruduce 2 ways, one is Function Module, the other is Class Static Method.
1. Using Funciton Moudle 'DX_FILE_EXISTENCE_CHECK'.
DATA: gdf_file_exist(1) TYPE c.
PARAMETERS p_file TYPE dxfile-filename.
AT SELECTION-SCREEN.
CALL FUNCTION 'DX_FILE_EXISTENCE_CHECK'
EXPORTING
filename = p_file
pc = 'X'
* SERVER =
IMPORTING
file_exists = gdf_file_exist
IF NOT ( sy-subrc = 0 and gdf_file_exist = 'X' )
MESSAGE 'the input file does not exist.' TYPE 'E'.
ENDIF.
Pay attention to the importing parameter 'pc', it should be set as 'X'.
2. Using Class Static Method 'CL_GUI_FRONTEND_SERVICES=>FILE_EXIST'
DATA: gdf_file_exist(1) TYPE c.
PARAMETERS p_file TYPE dxfile-filename.
AT SELECTION-SCREEN.
CALL METHOD cl_gui_frontend_services=>file_exist
EXPORTING
file = p_file
RECEIVING
result = gdf_file_exist
IF NOT ( sy-subrc = 0 and gdf_file_exist = 'X' )
MESSAGE 'the input file does not exist.' TYPE 'E'.
ENDIF.
application server file
For application server file, generally we open it first within the event 'AT SELECTION-SCREEN'.If it can be opened successfully, this file exists. After open, do not forget to close it.
PARAMETERS p_file TYPE dxfile-filename.
AT SELECTION-SCREEN.
OPEN DATASET p_file FOR INPUT IN TEXT MODE ENCODING DEFAULT.
IF sy-subrc = 0.
CLOSE DATASET p_file.
ELSE.
MESSAGE 'the input file does not exist.' TYPE 'E'.
ENDIF.
There is also a Function Module can be used, named 'OCS_GET_FILE_INFO'.
DATA: gdt_ocs_file TYPE TABLE OF ocs_file.
PARAMETERS p_file TYPE dxfile-filename.
AT SELECTION-SCREEN.
CALL FUNCTION 'OCS_GET_FILE_INFO'
EXPORTING
dir_name = p_file
file_name = '*'
TABLES
dir_list = gdt_ocs_file
Importing parameter 'file_name' is set as '*' means all the file in the specfied directory will be get and stored in the internal table 'gdt_ocs_file'. If the input file is included in the internal table, this file exists.
Add F4 Help
Adding one F4 Help to the file path on the selection-screen will be very helpful to the end-user.The logic should be under the event 'ON VALUE-REQUEST'.
presentation server file
For the presentation server file,here intruduce 2 ways, one is Function Module, the other is Class Static Method.
1. Using Funciton Moudle 'F4_FILENAME'.
PARAMETERS p_file TYPE dxfile-filename.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
CALL FUNCTION 'F4_FILENAME'
* EXPORTING
* PROGRAM_NAME =
* DYNPRO_NUMBER =
* FIELD_NAME =
IMPORTING
file_name = p_file.
2. Using Class Static Method 'CL_GUI_FRONTEND_SERVICES=>FILE_OPEN_DIALOG'.
DATA: gdt_filetable TYPE filetable.
DATA: gdf_rc TYPE I.
PARAMETERS p_file TYPE dxfile-filename.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
CALL METHOD cl_gui_frontend_services=>file_open_dialog
EXPORTING
WINDOW_TITLE = 'Choose a file'
CHANGING
file_table = gdt_filetable
rc = gdf_rc
IF sy-subrc = 0.
READ TABLE gdt_filetable
INTO gds_filetable INDEX 1.
p_file = gds_filetable-filename.
ENDIF.
gdf_rc is the number of selected file, if it is equal -1, error occured.
application server file
Generally it need not to provide F4 help for application server file. If we want it, there is also a Funciotn Module which can be used.
PARAMETERS p_file TYPE dxfile-filename.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
CALL FUNCTION 'F4_DXFILENAME_4_DYNP'
EXPORTING
dynpfield_filename = 'P_FILE'
dyname = sy-repid
dynumb = sy-dynnr
filetype = 'P'
location = 'A'
server = ' '.
filetype: 'P' represents Physical file name; 'L' represents Logical file name.
location: 'A' represents Application Server; 'P' represents Presentation server.
Download Files
Sometimes we need to save the internal table data as a file for the further process.For download to presentation server and download to application server,they are 2 different kinds of process methods.
to presentation server
When storing internal table data as a local file on the presentation server, there are 2 methods we can use.
One is using the function modeule, the other is using the class static method.
1. Using Function Module 'GUI_DOWNLOAD'.
DATA: gdf_filepath type dxfile-filename
DATA: gdt_data type table of gts_data.
START-OF-SELECTION.
gdf_filepath = 'C:\mydata.txt'.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = gdf_filepath
filetype = 'ASC'
write_field_separator = 'X'
TABLES
data_tab = gdt_data.
filetype is set by 'X' mens separating columns by Tabs in case of ASCII download.
If sy-subrc is equal 0, file downloading is successful.
2. Using class static method 'CL_GUI_FRONTEND_SERVICES =>GUI_DOWNLOAD'
DATA: gdf_filepath type dxfile-filename
DATA: gdt_data type table of gts_data.
START-OF-SELECTION.
gdf_filepath = 'C:\mydata.txt'.
CALL METHOD cl_gui_frontend_services=>gui_download
EXPORTING
filename = gdf_filepath
filetype = 'ASC'
write_field_separator = 'X'
CHANGING
data_tab = gdt_data
filetype is set by 'X' mens separating columns by Tabs in case of ASCII download.
If sy-subrc is equal 0, file downloading is successful.
to application server
If we want to save the internal table data to the application server, there is no function module or class static method which we can use, we must wirte the code by ourselves.
DATA: gdf_filepath type dxfile-filename
DATA: gdt_data type table of gts_data.
DATA: ldf_length type i.
FIELD-SYMBOLS:TYPE gts_data
START-OF-SELECTION.
gdf_filepath = 'C:\mydata.txt'.
OPEN DATASET gdf_filepath FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
LOOP AT prt_data ASSIGNING.
DESCRIBE FIELDLENGTH ldf_length IN BYTE MODE.
TRANSFERTO prf_file LENGTH ldf_length.
ENDLOOP.
CLOSE DATASET gdf_filepath.
The prerequsite is the field of prt_data must be character type.
Using this method, every field column will output as the length defined,without separator.
If we want field columns are separated by tab, we can realize it as below.
DATA: gdf_filepath type dxfile-filename
DATA: gdt_data type table of gts_data.
DATA: ldf_length type i.
FIELD-SYMBOLS:TYPE gts_data
START-OF-SELECTION.
gdf_filepath = 'C:\mydata.txt'.
OPEN DATASET gdf_filepath FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
LOOP AT prt_data ASSIGNING.
CONCATENATE-BUKRS
-BUDAT
...
INTO LDF_OUTDATA
SEPARATED BY
CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
TRANSFER LDF_OUTDATA TO gdf_filepath.
ENDLOOP.
CLOSE DATASET gdf_filepath.
Upload Files
Sometimes we need to upload the file data to the internal table first, and then process it.For upload from presentation server and upload from application server,they are 2 different kinds of process methods.
from presentation server
When we upload a file data from presentation server to the internal table, there are 2 method that we can choose.One is using the Function Moduel, the other is using the class static method.
1. Using function module 'GUI_UPLOAD'.
DATA: gdt_filedata TYPE TABLE OF gts_filedata.
PARAMETERS p_file TYPE dxfile-filename.
START-OF-SELECTION.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = p_file
has_field_separator = 'X'
TABLES
data_tab = gdt_filedata
parameter has_field_separator is set as 'X' means columns separated by tabs in case of ASCII upload.
2. Using the class tatic method 'CL_GUI_FRONTEND_SERVICES =>GUI_UPLOAD'.
DATA: gdt_filedata TYPE TABLE OF gts_filedata.
PARAMETERS p_file TYPE dxfile-filename.
START-OF-SELECTION.
CALL METHOD cl_gui_frontend_services=>gui_upload
EXPORTING
filename = p_file
has_field_separator = 'X'
CHANGING
data_tab = prt_table.
parameter 'has_field_separator' is set as 'X' means columns separated by tabs in case of ASCII upload.
from application server
If we want to upload file data from the application server to the internal table, there is no function module or class static method which we can use, we must wirte the code by ourselves.
1. For the file data which has no seperator between field columns.
PARAMETERS p_file TYPE dxfile-filename.
START-OF-SELECTION.
OPEN DATASET p_file IN TEXT MODE ENCODING DEFAULT FOR INPUT.
DO.
READ DATASET p_file INTO gds_data.
IF sy-subrc <> 0.
EXIT.
ENDIF.
APPEND gds_data TO gdt_data.
ENDDO.
CLOSE DATASET p_file.
2. For the file data which has tab separator between field columns.
DATA: gds_field_split type gts_data.
FIELD-SYMBOLS:TYPE gts_data.
PARAMETERS p_file TYPE dxfile-filename.
START-OF-SELECTION.
OPEN DATASET prf_file IN TEXT MODE ENCODING DEFAULT FOR INPUT.
DO.
READ DATASET p_file INTO gds_field.
SPLIT gds_field AT cl_abap_char_utilities=>horizontal_tab
INTO TABLE gdt_field_split.
LOOP AT gdt_field_split into gds_field_split.
gdf_index = gdf_index + 1.
ASSIGN COMPONENT gdf_index OF STRUCTURE
gds_data to.
IF sy-subrc = 0.
= gds_field_split.
ENDIF.
ENDLOOP.
APPEND gds_data TO gdt_data.
ENDDO.
CLOSE DATASET p_file.
Check File Existence
Before we process the file which is input on the selection screen by end-user, we need to check whether this file exists or not. If it does not exist, we just give an error message and need not to go into the main program .This logic should be done within the event 'AT SELECTION-SCREEN'.
presentation server file
For the presentation server file,here intruduce 2 ways, one is Function Module, the other is Class Static Method.
1. Using Funciton Moudle 'DX_FILE_EXISTENCE_CHECK'.
DATA: gdf_file_exist(1) TYPE c.
PARAMETERS p_file TYPE dxfile-filename.
AT SELECTION-SCREEN.
CALL FUNCTION 'DX_FILE_EXISTENCE_CHECK'
EXPORTING
filename = p_file
pc = 'X'
* SERVER =
IMPORTING
file_exists = gdf_file_exist
IF NOT ( sy-subrc = 0 and gdf_file_exist = 'X' )
MESSAGE 'the input file does not exist.' TYPE 'E'.
ENDIF.
Pay attention to the importing parameter 'pc', it should be set as 'X'.
2. Using Class Static Method 'CL_GUI_FRONTEND_SERVICES=>FILE_EXIST'
DATA: gdf_file_exist(1) TYPE c.
PARAMETERS p_file TYPE dxfile-filename.
AT SELECTION-SCREEN.
CALL METHOD cl_gui_frontend_services=>file_exist
EXPORTING
file = p_file
RECEIVING
result = gdf_file_exist
IF NOT ( sy-subrc = 0 and gdf_file_exist = 'X' )
MESSAGE 'the input file does not exist.' TYPE 'E'.
ENDIF.
application server file
For application server file, generally we open it first within the event 'AT SELECTION-SCREEN'.If it can be opened successfully, this file exists. After open, do not forget to close it.
PARAMETERS p_file TYPE dxfile-filename.
AT SELECTION-SCREEN.
OPEN DATASET p_file FOR INPUT IN TEXT MODE ENCODING DEFAULT.
IF sy-subrc = 0.
CLOSE DATASET p_file.
ELSE.
MESSAGE 'the input file does not exist.' TYPE 'E'.
ENDIF.
There is also a Function Module can be used, named 'OCS_GET_FILE_INFO'.
DATA: gdt_ocs_file TYPE TABLE OF ocs_file.
PARAMETERS p_file TYPE dxfile-filename.
AT SELECTION-SCREEN.
CALL FUNCTION 'OCS_GET_FILE_INFO'
EXPORTING
dir_name = p_file
file_name = '*'
TABLES
dir_list = gdt_ocs_file
Importing parameter 'file_name' is set as '*' means all the file in the specfied directory will be get and stored in the internal table 'gdt_ocs_file'. If the input file is included in the internal table, this file exists.
Add F4 Help
Adding one F4 Help to the file path on the selection-screen will be very helpful to the end-user.The logic should be under the event 'ON VALUE-REQUEST'.
presentation server file
For the presentation server file,here intruduce 2 ways, one is Function Module, the other is Class Static Method.
1. Using Funciton Moudle 'F4_FILENAME'.
PARAMETERS p_file TYPE dxfile-filename.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
CALL FUNCTION 'F4_FILENAME'
* EXPORTING
* PROGRAM_NAME =
* DYNPRO_NUMBER =
* FIELD_NAME =
IMPORTING
file_name = p_file.
2. Using Class Static Method 'CL_GUI_FRONTEND_SERVICES=>FILE_OPEN_DIALOG'.
DATA: gdt_filetable TYPE filetable.
DATA: gdf_rc TYPE I.
PARAMETERS p_file TYPE dxfile-filename.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
CALL METHOD cl_gui_frontend_services=>file_open_dialog
EXPORTING
WINDOW_TITLE = 'Choose a file'
CHANGING
file_table = gdt_filetable
rc = gdf_rc
IF sy-subrc = 0.
READ TABLE gdt_filetable
INTO gds_filetable INDEX 1.
p_file = gds_filetable-filename.
ENDIF.
gdf_rc is the number of selected file, if it is equal -1, error occured.
application server file
Generally it need not to provide F4 help for application server file. If we want it, there is also a Funciotn Module which can be used.
PARAMETERS p_file TYPE dxfile-filename.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
CALL FUNCTION 'F4_DXFILENAME_4_DYNP'
EXPORTING
dynpfield_filename = 'P_FILE'
dyname = sy-repid
dynumb = sy-dynnr
filetype = 'P'
location = 'A'
server = ' '.
filetype: 'P' represents Physical file name; 'L' represents Logical file name.
location: 'A' represents Application Server; 'P' represents Presentation server.
Download Files
Sometimes we need to save the internal table data as a file for the further process.For download to presentation server and download to application server,they are 2 different kinds of process methods.
to presentation server
When storing internal table data as a local file on the presentation server, there are 2 methods we can use.
One is using the function modeule, the other is using the class static method.
1. Using Function Module 'GUI_DOWNLOAD'.
DATA: gdf_filepath type dxfile-filename
DATA: gdt_data type table of gts_data.
START-OF-SELECTION.
gdf_filepath = 'C:\mydata.txt'.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = gdf_filepath
filetype = 'ASC'
write_field_separator = 'X'
TABLES
data_tab = gdt_data.
filetype is set by 'X' mens separating columns by Tabs in case of ASCII download.
If sy-subrc is equal 0, file downloading is successful.
2. Using class static method 'CL_GUI_FRONTEND_SERVICES =>GUI_DOWNLOAD'
DATA: gdf_filepath type dxfile-filename
DATA: gdt_data type table of gts_data.
START-OF-SELECTION.
gdf_filepath = 'C:\mydata.txt'.
CALL METHOD cl_gui_frontend_services=>gui_download
EXPORTING
filename = gdf_filepath
filetype = 'ASC'
write_field_separator = 'X'
CHANGING
data_tab = gdt_data
filetype is set by 'X' mens separating columns by Tabs in case of ASCII download.
If sy-subrc is equal 0, file downloading is successful.
to application server
If we want to save the internal table data to the application server, there is no function module or class static method which we can use, we must wirte the code by ourselves.
DATA: gdf_filepath type dxfile-filename
DATA: gdt_data type table of gts_data.
DATA: ldf_length type i.
FIELD-SYMBOLS:
START-OF-SELECTION.
gdf_filepath = 'C:\mydata.txt'.
OPEN DATASET gdf_filepath FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
LOOP AT prt_data ASSIGNING
DESCRIBE FIELD
TRANSFER
ENDLOOP.
CLOSE DATASET gdf_filepath.
The prerequsite is the field of prt_data must be character type.
Using this method, every field column will output as the length defined,without separator.
If we want field columns are separated by tab, we can realize it as below.
DATA: gdf_filepath type dxfile-filename
DATA: gdt_data type table of gts_data.
DATA: ldf_length type i.
FIELD-SYMBOLS:
START-OF-SELECTION.
gdf_filepath = 'C:\mydata.txt'.
OPEN DATASET gdf_filepath FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
LOOP AT prt_data ASSIGNING
CONCATENATE
...
INTO LDF_OUTDATA
SEPARATED BY
CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
TRANSFER LDF_OUTDATA TO gdf_filepath.
ENDLOOP.
CLOSE DATASET gdf_filepath.
Upload Files
Sometimes we need to upload the file data to the internal table first, and then process it.For upload from presentation server and upload from application server,they are 2 different kinds of process methods.
from presentation server
When we upload a file data from presentation server to the internal table, there are 2 method that we can choose.One is using the Function Moduel, the other is using the class static method.
1. Using function module 'GUI_UPLOAD'.
DATA: gdt_filedata TYPE TABLE OF gts_filedata.
PARAMETERS p_file TYPE dxfile-filename.
START-OF-SELECTION.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = p_file
has_field_separator = 'X'
TABLES
data_tab = gdt_filedata
parameter has_field_separator is set as 'X' means columns separated by tabs in case of ASCII upload.
2. Using the class tatic method 'CL_GUI_FRONTEND_SERVICES =>GUI_UPLOAD'.
DATA: gdt_filedata TYPE TABLE OF gts_filedata.
PARAMETERS p_file TYPE dxfile-filename.
START-OF-SELECTION.
CALL METHOD cl_gui_frontend_services=>gui_upload
EXPORTING
filename = p_file
has_field_separator = 'X'
CHANGING
data_tab = prt_table.
parameter 'has_field_separator' is set as 'X' means columns separated by tabs in case of ASCII upload.
from application server
If we want to upload file data from the application server to the internal table, there is no function module or class static method which we can use, we must wirte the code by ourselves.
1. For the file data which has no seperator between field columns.
PARAMETERS p_file TYPE dxfile-filename.
START-OF-SELECTION.
OPEN DATASET p_file IN TEXT MODE ENCODING DEFAULT FOR INPUT.
DO.
READ DATASET p_file INTO gds_data.
IF sy-subrc <> 0.
EXIT.
ENDIF.
APPEND gds_data TO gdt_data.
ENDDO.
CLOSE DATASET p_file.
2. For the file data which has tab separator between field columns.
DATA: gds_field_split type gts_data.
FIELD-SYMBOLS:
PARAMETERS p_file TYPE dxfile-filename.
START-OF-SELECTION.
OPEN DATASET prf_file IN TEXT MODE ENCODING DEFAULT FOR INPUT.
DO.
READ DATASET p_file INTO gds_field.
SPLIT gds_field AT cl_abap_char_utilities=>horizontal_tab
INTO TABLE gdt_field_split.
LOOP AT gdt_field_split into gds_field_split.
gdf_index = gdf_index + 1.
ASSIGN COMPONENT gdf_index OF STRUCTURE
gds_data to
IF sy-subrc = 0.
ENDIF.
ENDLOOP.
APPEND gds_data TO gdt_data.
ENDDO.
CLOSE DATASET p_file.
ABAP - Program For Finding Hardcoded Text.
*---------------------------------------------------------------------*
* Report Name: Z_TEST_HARD_CODING
*
* Desc : Detecting hard coding in Programs
* Author : Arun Nair
*---------------------------------------------------------------------*
REPORT z_test_hard_coding NO STANDARD PAGE HEADING
LINE-SIZE 180
LINE-COUNT 45.
*---------------------------------------------------------------------*
* DATA DECLARATION *
*---------------------------------------------------------------------*
TYPES: BEGIN OF ty_ztab,
prog TYPE programm,
END OF ty_ztab.
TYPES: BEGIN OF ty_zprog,
line TYPE char72,
END OF ty_zprog.
TYPES: BEGIN OF ty_zprogdet,
prog TYPE programm,
linenr TYPE i,
line TYPE char72,
END OF ty_zprogdet.
DATA: i_prog TYPE STANDARD TABLE OF ty_ztab,
wa_prog TYPE ty_ztab.
DATA: i_zprog TYPE STANDARD TABLE OF ty_zprog,
wa_zprog TYPE ty_zprog.
DATA: i_zprogdet TYPE STANDARD TABLE OF ty_zprogdet,
wa_zprogdet TYPE ty_zprogdet.
PARAMETERS: p_hard TYPE char25 OBLIGATORY.
PARAMETERS: p_chk TYPE char25 OBLIGATORY DEFAULT 'Z*'.
PARAMETERS: p_full RADIOBUTTON GROUP g1,
p_nam RADIOBUTTON GROUP g1.
*---------------------------------------------------------------------*
* START OF SELECTION *
*---------------------------------------------------------------------*
START-OF-SELECTION.
*-- Replace * by %
REPLACE ALL OCCURRENCES OF '*' IN p_chk WITH '%'.
*--get the list of programs
SELECT prog FROM d010sinf
INTO TABLE i_prog
WHERE prog LIKE p_chk.
IF sy-subrc = 0.
LOOP AT i_prog INTO wa_prog.
READ REPORT wa_prog-prog INTO i_zprog.
IF sy-subrc = 0.
LOOP AT i_zprog INTO wa_zprog.
IF wa_zprog-line CS p_hard.
wa_zprogdet-prog = wa_prog-prog.
wa_zprogdet-line = wa_zprog-line.
wa_zprogdet-linenr = sy-tabix.
APPEND wa_zprogdet TO i_zprogdet.
CLEAR wa_zprogdet.
ENDIF.
ENDLOOP.
ENDIF.
ENDLOOP.
ELSE.
*-- Message - No entries found
ENDIF.
IF i_zprogdet IS INITIAL.
*-- Message - No entries found
ENDIF.
*---------------------------------------------------------------------*
* END OF SELECTION *
*---------------------------------------------------------------------*
END-OF-SELECTION.
*-- Display report
LOOP AT i_zprogdet INTO wa_zprogdet.
AT NEW prog.
IF p_full EQ 'X'.
SKIP.
WRITE: / wa_zprogdet-prog COLOR 4.
SKIP.
ELSE.
WRITE: / wa_zprogdet-prog COLOR 4.
ENDIF.
ENDAT.
IF p_full EQ 'X'.
WRITE: / wa_zprogdet-prog,
'LINE Nr:',
wa_zprogdet-linenr,
wa_zprogdet-line COLOR 2.
ENDIF.
ENDLOOP.
* Report Name: Z_TEST_HARD_CODING
*
* Desc : Detecting hard coding in Programs
* Author : Arun Nair
*---------------------------------------------------------------------*
REPORT z_test_hard_coding NO STANDARD PAGE HEADING
LINE-SIZE 180
LINE-COUNT 45.
*---------------------------------------------------------------------*
* DATA DECLARATION *
*---------------------------------------------------------------------*
TYPES: BEGIN OF ty_ztab,
prog TYPE programm,
END OF ty_ztab.
TYPES: BEGIN OF ty_zprog,
line TYPE char72,
END OF ty_zprog.
TYPES: BEGIN OF ty_zprogdet,
prog TYPE programm,
linenr TYPE i,
line TYPE char72,
END OF ty_zprogdet.
DATA: i_prog TYPE STANDARD TABLE OF ty_ztab,
wa_prog TYPE ty_ztab.
DATA: i_zprog TYPE STANDARD TABLE OF ty_zprog,
wa_zprog TYPE ty_zprog.
DATA: i_zprogdet TYPE STANDARD TABLE OF ty_zprogdet,
wa_zprogdet TYPE ty_zprogdet.
PARAMETERS: p_hard TYPE char25 OBLIGATORY.
PARAMETERS: p_chk TYPE char25 OBLIGATORY DEFAULT 'Z*'.
PARAMETERS: p_full RADIOBUTTON GROUP g1,
p_nam RADIOBUTTON GROUP g1.
*---------------------------------------------------------------------*
* START OF SELECTION *
*---------------------------------------------------------------------*
START-OF-SELECTION.
*-- Replace * by %
REPLACE ALL OCCURRENCES OF '*' IN p_chk WITH '%'.
*--get the list of programs
SELECT prog FROM d010sinf
INTO TABLE i_prog
WHERE prog LIKE p_chk.
IF sy-subrc = 0.
LOOP AT i_prog INTO wa_prog.
READ REPORT wa_prog-prog INTO i_zprog.
IF sy-subrc = 0.
LOOP AT i_zprog INTO wa_zprog.
IF wa_zprog-line CS p_hard.
wa_zprogdet-prog = wa_prog-prog.
wa_zprogdet-line = wa_zprog-line.
wa_zprogdet-linenr = sy-tabix.
APPEND wa_zprogdet TO i_zprogdet.
CLEAR wa_zprogdet.
ENDIF.
ENDLOOP.
ENDIF.
ENDLOOP.
ELSE.
*-- Message - No entries found
ENDIF.
IF i_zprogdet IS INITIAL.
*-- Message - No entries found
ENDIF.
*---------------------------------------------------------------------*
* END OF SELECTION *
*---------------------------------------------------------------------*
END-OF-SELECTION.
*-- Display report
LOOP AT i_zprogdet INTO wa_zprogdet.
AT NEW prog.
IF p_full EQ 'X'.
SKIP.
WRITE: / wa_zprogdet-prog COLOR 4.
SKIP.
ELSE.
WRITE: / wa_zprogdet-prog COLOR 4.
ENDIF.
ENDAT.
IF p_full EQ 'X'.
WRITE: / wa_zprogdet-prog,
'LINE Nr:',
wa_zprogdet-linenr,
wa_zprogdet-line COLOR 2.
ENDIF.
ENDLOOP.
ABAP - Creating SAP Shortcut At RUN Time.
The following function module can be used to create a shortcut for any SAP transaction.
Further, certain values available in the transaction can be defaulted by passing the values as parameters to this FM. This shortcut created can then be attached in a mail and sent to the appropriate recipients.
FUNCTION zfm_create_shortcut.
*"---------------------------------------------------------------------
*"*"Local Interface:
*" IMPORTING
*" REFERENCE(RECIPIENT_USER_ID) TYPE SYUNAME
*" REFERENCE(TRANSACTION) TYPE TCODE
*" EXPORTING
*" REFERENCE(CONTENT) TYPE STRING
*" TABLES
*" SHORTCUT_PARAM STRUCTURE ZST_SHORTCUT_PAR OPTIONAL
*"---------------------------------------------------------------------
*** Declaration for shortcut content
DATA : parameter TYPE text255,
v_pernr(12) TYPE c.
DATA : v_tcode TYPE tcode.
* Check if transaction code is available
CLEAR v_tcode.
SELECT SINGLE tcode FROM tstc
INTO v_tcode
WHERE tcode EQ transaction.
IF v_tcode IS INITIAL.
MESSAGE 'Enter a valid transaction' TYPE 'E' DISPLAY LIKE 'A'.
EXIT.
ENDIF.
* Populate the parameters to be passed to the shortcut
IF NOT shortcut_param[] IS INITIAL.
CLEAR parameter.
LOOP AT shortcut_param.
CONCATENATE parameter shortcut_param-fieldname '='
shortcut_param-fieldvalue ';'
INTO parameter.
ENDLOOP.
ENDIF.
*** create the shortcut content for the required transaction
CALL FUNCTION 'SWN_CREATE_SHORTCUT'
EXPORTING
i_transaction = transaction
i_parameter = parameter
i_sysid = sy-sysid
i_client = sy-mandt
i_user = recipient_user_id
i_language = sy-langu
i_windowsize = 'Normal window'
IMPORTING
shortcut_string = content
EXCEPTIONS
inconsistent_parameters = 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.
ENDIF.
ENDFUNCTION.
This FM receives RECIPIENT_USER_ID and TRANSACTION as import parameters.
The value of parameters if any can be passed through table parameter SHORCTCUT_PARAM.
On execution the shortcut content is created and returned through the export parameter "CONTENT".
The table SHORTCUT_PARAM refers to a custom structure described in Appendix 1.
Example scenario
Consider a scenario where the employee has requested for a change in address.
Now once the change in address is completed a notification email is sent to the employee
indicating the successful change in address. In a normal scenario the employee needs
to log into the system manually and enter the required transaction. Then the required
details (employee number, infotype and subtype) need to be entered before displaying
the updated information.
This process can be simplified by sending a shortcut which will navigate the user to
the required transaction with all required data pre-loaded.
The sample code for this process is given below,
*&---------------------------------------------------------------------*
*& Report ZRP_MAIL_SHORTCUT
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT zrp_mail_shortcut.
************************************************************************
*** Report to send mail to employee to display temp address ***
************************************************************************
*** Declarations for attachment creation
DATA: doc_chng LIKE sodocchgi1.
DATA: tab_lines LIKE sy-tabix,
body_start LIKE sy-tabix.
DATA: it_objtxt LIKE solisti1 OCCURS 0 WITH HEADER LINE.
DATA: it_objpack LIKE sopcklsti1 OCCURS 2 WITH HEADER LINE.
DATA: it_objbin LIKE solisti1 OCCURS 10 WITH HEADER LINE.
DATA: it_reclist LIKE somlreci1 OCCURS 5 WITH HEADER LINE.
DATA: it_shortcut_param LIKE zst_shortcut_par OCCURS 0 WITH HEADER LINE.
DATA: content TYPE string.
*** Pass the required parameters and create the shortcut
CLEAR it_shortcut_param.
REFRESH it_shortcut_param.
it_shortcut_param-fieldname = 'RP50G-PERNR'.
it_shortcut_param-fieldvalue = '1001'. "Employee number
APPEND it_shortcut_param.
it_shortcut_param-fieldname = 'RP50G-CHOIC'.
it_shortcut_param-fieldvalue = '0006'. " Address Infotype
APPEND it_shortcut_param.
it_shortcut_param-fieldname = 'RP50G-TIMR1'.
it_shortcut_param-fieldvalue = 'X'. "Period selected as "Today"
APPEND it_shortcut_param.
it_shortcut_param-fieldname = 'RP50G-SUBTY'.
it_shortcut_param-fieldvalue = '2'. "Temporary address subtype
APPEND it_shortcut_param.
CALL FUNCTION 'ZFM_CREATE_SHORTCUT'
EXPORTING
recipient_user_id = 'DEVHYD'
transaction = 'PA20'
IMPORTING
content = content
TABLES
shortcut_param = it_shortcut_param.
*** Mail Subject
doc_chng-obj_descr = 'Employee address changed'.
*** Mail Contents
CONCATENATE ' The requested change has been made to your temporary address.'
' Please double click on the attachment and choose display to view the updated address'
INTO it_objtxt.
APPEND it_objtxt.
*** Creation of the entry for the document
DESCRIBE TABLE it_objtxt LINES tab_lines.
CLEAR it_objpack-transf_bin.
it_objpack-head_start = 1.
it_objpack-head_num = 0.
it_objpack-body_start = 1.
it_objpack-body_num = tab_lines.
it_objpack-doc_type = 'RAW'.
APPEND it_objpack.
*** Populate attachment content
CLEAR : tab_lines, it_objbin.
CONCATENATE content it_objbin-line INTO it_objbin-line.
APPEND it_objbin.
DESCRIBE TABLE it_objbin LINES tab_lines.
*** Creation of the entry for the compressed attachment
it_objpack-transf_bin = 'X'. "Will get content from content_bin
it_objpack-head_start = 1.
it_objpack-head_num = 1.
it_objpack-body_start = 1.
it_objpack-body_num = tab_lines.
it_objpack-doc_type = 'EXT'.
it_objpack-obj_name = 'SAPSHORTCUTMAIL'.
it_objpack-obj_descr = 'DisplayAddress.SAP'.
it_objpack-doc_size = tab_lines * 255.
APPEND it_objpack.
*** target recipent(s)
CLEAR it_reclist.
it_reclist-receiver = 'employeemailid@employeecompany.com'.
it_reclist-rec_type = 'U'.
APPEND it_reclist.
*** Sending the document to recipients with the shortcut attachment
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = doc_chng
put_in_outbox = 'X'
commit_work = 'X'
TABLES
packing_list = it_objpack
contents_bin = it_objbin
contents_txt = it_objtxt
receivers = it_reclist
EXCEPTIONS
too_many_receivers = 1
document_not_sent = 2
operation_no_authorization = 4
OTHERS = 99.
Further, certain values available in the transaction can be defaulted by passing the values as parameters to this FM. This shortcut created can then be attached in a mail and sent to the appropriate recipients.
FUNCTION zfm_create_shortcut.
*"---------------------------------------------------------------------
*"*"Local Interface:
*" IMPORTING
*" REFERENCE(RECIPIENT_USER_ID) TYPE SYUNAME
*" REFERENCE(TRANSACTION) TYPE TCODE
*" EXPORTING
*" REFERENCE(CONTENT) TYPE STRING
*" TABLES
*" SHORTCUT_PARAM STRUCTURE ZST_SHORTCUT_PAR OPTIONAL
*"---------------------------------------------------------------------
*** Declaration for shortcut content
DATA : parameter TYPE text255,
v_pernr(12) TYPE c.
DATA : v_tcode TYPE tcode.
* Check if transaction code is available
CLEAR v_tcode.
SELECT SINGLE tcode FROM tstc
INTO v_tcode
WHERE tcode EQ transaction.
IF v_tcode IS INITIAL.
MESSAGE 'Enter a valid transaction' TYPE 'E' DISPLAY LIKE 'A'.
EXIT.
ENDIF.
* Populate the parameters to be passed to the shortcut
IF NOT shortcut_param[] IS INITIAL.
CLEAR parameter.
LOOP AT shortcut_param.
CONCATENATE parameter shortcut_param-fieldname '='
shortcut_param-fieldvalue ';'
INTO parameter.
ENDLOOP.
ENDIF.
*** create the shortcut content for the required transaction
CALL FUNCTION 'SWN_CREATE_SHORTCUT'
EXPORTING
i_transaction = transaction
i_parameter = parameter
i_sysid = sy-sysid
i_client = sy-mandt
i_user = recipient_user_id
i_language = sy-langu
i_windowsize = 'Normal window'
IMPORTING
shortcut_string = content
EXCEPTIONS
inconsistent_parameters = 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.
ENDIF.
ENDFUNCTION.
This FM receives RECIPIENT_USER_ID and TRANSACTION as import parameters.
The value of parameters if any can be passed through table parameter SHORCTCUT_PARAM.
On execution the shortcut content is created and returned through the export parameter "CONTENT".
The table SHORTCUT_PARAM refers to a custom structure described in Appendix 1.
Example scenario
Consider a scenario where the employee has requested for a change in address.
Now once the change in address is completed a notification email is sent to the employee
indicating the successful change in address. In a normal scenario the employee needs
to log into the system manually and enter the required transaction. Then the required
details (employee number, infotype and subtype) need to be entered before displaying
the updated information.
This process can be simplified by sending a shortcut which will navigate the user to
the required transaction with all required data pre-loaded.
The sample code for this process is given below,
*&---------------------------------------------------------------------*
*& Report ZRP_MAIL_SHORTCUT
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT zrp_mail_shortcut.
************************************************************************
*** Report to send mail to employee to display temp address ***
************************************************************************
*** Declarations for attachment creation
DATA: doc_chng LIKE sodocchgi1.
DATA: tab_lines LIKE sy-tabix,
body_start LIKE sy-tabix.
DATA: it_objtxt LIKE solisti1 OCCURS 0 WITH HEADER LINE.
DATA: it_objpack LIKE sopcklsti1 OCCURS 2 WITH HEADER LINE.
DATA: it_objbin LIKE solisti1 OCCURS 10 WITH HEADER LINE.
DATA: it_reclist LIKE somlreci1 OCCURS 5 WITH HEADER LINE.
DATA: it_shortcut_param LIKE zst_shortcut_par OCCURS 0 WITH HEADER LINE.
DATA: content TYPE string.
*** Pass the required parameters and create the shortcut
CLEAR it_shortcut_param.
REFRESH it_shortcut_param.
it_shortcut_param-fieldname = 'RP50G-PERNR'.
it_shortcut_param-fieldvalue = '1001'. "Employee number
APPEND it_shortcut_param.
it_shortcut_param-fieldname = 'RP50G-CHOIC'.
it_shortcut_param-fieldvalue = '0006'. " Address Infotype
APPEND it_shortcut_param.
it_shortcut_param-fieldname = 'RP50G-TIMR1'.
it_shortcut_param-fieldvalue = 'X'. "Period selected as "Today"
APPEND it_shortcut_param.
it_shortcut_param-fieldname = 'RP50G-SUBTY'.
it_shortcut_param-fieldvalue = '2'. "Temporary address subtype
APPEND it_shortcut_param.
CALL FUNCTION 'ZFM_CREATE_SHORTCUT'
EXPORTING
recipient_user_id = 'DEVHYD'
transaction = 'PA20'
IMPORTING
content = content
TABLES
shortcut_param = it_shortcut_param.
*** Mail Subject
doc_chng-obj_descr = 'Employee address changed'.
*** Mail Contents
CONCATENATE ' The requested change has been made to your temporary address.'
' Please double click on the attachment and choose display to view the updated address'
INTO it_objtxt.
APPEND it_objtxt.
*** Creation of the entry for the document
DESCRIBE TABLE it_objtxt LINES tab_lines.
CLEAR it_objpack-transf_bin.
it_objpack-head_start = 1.
it_objpack-head_num = 0.
it_objpack-body_start = 1.
it_objpack-body_num = tab_lines.
it_objpack-doc_type = 'RAW'.
APPEND it_objpack.
*** Populate attachment content
CLEAR : tab_lines, it_objbin.
CONCATENATE content it_objbin-line INTO it_objbin-line.
APPEND it_objbin.
DESCRIBE TABLE it_objbin LINES tab_lines.
*** Creation of the entry for the compressed attachment
it_objpack-transf_bin = 'X'. "Will get content from content_bin
it_objpack-head_start = 1.
it_objpack-head_num = 1.
it_objpack-body_start = 1.
it_objpack-body_num = tab_lines.
it_objpack-doc_type = 'EXT'.
it_objpack-obj_name = 'SAPSHORTCUTMAIL'.
it_objpack-obj_descr = 'DisplayAddress.SAP'.
it_objpack-doc_size = tab_lines * 255.
APPEND it_objpack.
*** target recipent(s)
CLEAR it_reclist.
it_reclist-receiver = 'employeemailid@employeecompany.com'.
it_reclist-rec_type = 'U'.
APPEND it_reclist.
*** Sending the document to recipients with the shortcut attachment
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = doc_chng
put_in_outbox = 'X'
commit_work = 'X'
TABLES
packing_list = it_objpack
contents_bin = it_objbin
contents_txt = it_objtxt
receivers = it_reclist
EXCEPTIONS
too_many_receivers = 1
document_not_sent = 2
operation_no_authorization = 4
OTHERS = 99.
Subscribe to:
Posts (Atom)