Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

IDoc batches Spliting.

Former Member
0 Likes
469

My requirement :

ZSCB : In this Custom Transaction code..we are doing the payements and in that ZAP1(<50000) and ZAP2(>50000)

two payemnts Methods through we are apporiving payment after that it generate IDocs.

In that IDoc now we have Intermediate folder after that archive folder and Outbound folder (last) in AL11 when im checking in outbound it it is not combinig all,if i did the payment in the sametime.

Now i want to change to ZAP1 into one folder and ZAP2 into another folder under Intermediate folder.

If i did <50000 payment den it goes to the ZAP1 and same for ZAP2.

please help him..

&----


*& Report ZFII_COMBINE_IDOC_FILES

*&

&----


*&

*&

&----


REPORT zfii_combine_idoc_files LINE-SIZE 255.

******************************************************

  • Data declaration

******************************************************

CONSTANTS: c_segment(7) TYPE c VALUE 'E2IDKU3',

c_sysid LIKE sy-sysid VALUE 'DEV',

c_segment2(10) TYPE c VALUE 'E2EDP02001',

c_qualf(3) TYPE c VALUE '009'.

DATA: v_dirlist TYPE eps2filnam VALUE '/usr/sap/DEV/interface/scbpayment/intermediate/' ,

v_outbound TYPE eps2filnam VALUE '/usr/sap/DEV/interface/scbpayment/outbound/' ,

v_archive TYPE eps2filnam VALUE '/usr/sap/DEV/interface/scbpayment/archive/' .

DATA: it_dirlist LIKE eps2fili OCCURS 10 WITH HEADER LINE,

temp_dirlist LIKE eps2fili OCCURS 10 WITH HEADER LINE.

DATA: BEGIN OF it_data OCCURS 3,

char(1000) TYPE c,

END OF it_data.

DATA: wa_data LIKE LINE OF it_data.

DATA: BEGIN OF temp_data OCCURS 3,

char(1000) TYPE c,

END OF temp_data.

******************************************************

  • START-OF-SELECTION.

******************************************************

START-OF-SELECTION.

IF sy-sysid NE c_sysid.

PERFORM directory_switching.

ENDIF.

PERFORM read_dir TABLES it_dirlist USING v_dirlist.

PERFORM open_dataset.

WRITE:/ 'End of log.'.

******************************************************

  • END-OF-SELECTION.

******************************************************

END-OF-SELECTION.

******************************************************

  • Form Read Dir

******************************************************

FORM read_dir TABLES ip_dirlist STRUCTURE it_dirlist USING p_dirlist.

***

CALL FUNCTION 'EPS2_GET_DIRECTORY_LISTING'

EXPORTING

iv_dir_name = p_dirlist

  • FILE_MASK = ' '

  • IMPORTING

  • DIR_NAME =

  • FILE_COUNTER =

  • ERROR_COUNTER =

TABLES

dir_list = ip_dirlist

EXCEPTIONS

invalid_eps_subdir = 1

sapgparam_failed = 2

build_directory_failed = 3

no_authorization = 4

read_directory_failed = 5

too_many_read_errors = 6

empty_directory_list = 7

OTHERS = 8

.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ELSE.

  • for now read O_*

  • LOOP AT ip_dirlist.

  • IF ip_dirlist-name+0(2) = 'O_' .

  • ELSE.

  • DELETE ip_dirlist.

  • ENDIF.

  • ENDLOOP.

ENDIF.

ENDFORM. "read_dir

&----


*& Form OPEN_DATASET

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM open_dataset .

DATA: p_file TYPE eps2filnam,

ptext(50),

n_file TYPE i,

n_run TYPE i,

v_payrunid LIKE reguh-laufi,

v_payrundt LIKE reguh-laufd,

t_payrunid LIKE reguh-laufi,

t_payrundt LIKE reguh-laufd,

v_crtfile TYPE c,

v_nofile TYPE i,

v_lines TYPE i.

DATA: results TYPE match_result_tab,

wa_results LIKE LINE OF results.

  • Sorting so files of the same batch are sorted together

SORT it_dirlist BY name.

DESCRIBE TABLE it_dirlist LINES v_nofile.

LOOP AT it_dirlist.

v_lines = v_lines + 1.

p_file = v_dirlist.

CONCATENATE p_file it_dirlist-name INTO p_file.

OPEN DATASET p_file FOR INPUT IN TEXT MODE ENCODING DEFAULT MESSAGE ptext.

IF sy-subrc EQ '0'.

WHILE sy-subrc = 0.

READ DATASET p_file INTO temp_data-char.

APPEND temp_data.

CLEAR temp_data.

ENDWHILE.

CLOSE DATASET p_file.

IF sy-subrc EQ '0'.

WRITE:/ 'File' , it_dirlist-name0(22) , 'read from' , v_dirlist0(47).

ELSE.

WRITE:/ 'File' , it_dirlist-name0(22) , 'could not be closed, from' , v_dirlist0(47).

ENDIF.

temp_dirlist = it_dirlist.

APPEND temp_dirlist.

  • Create backup file

PERFORM create_backup_file TABLES temp_dirlist

temp_data

USING it_dirlist-name.

ELSE.

WRITE:/ 'File' , it_dirlist-name0(22) , 'could not be read from' , v_dirlist0(47).

WRITE:/ ptext.

ENDIF.

n_file = n_file + 1.

IF n_file = '1'.

it_data[] = temp_data[].

DELETE it_data WHERE char IS INITIAL.

REFRESH temp_data.

FIND FIRST OCCURRENCE OF c_segment IN TABLE

it_data RESULTS wa_results.

IF sy-subrc EQ '0'.

READ TABLE it_data INTO wa_data INDEX wa_results-line.

IF sy-subrc EQ '0'.

v_payrunid = wa_data+82(6).

v_payrundt = wa_data+88(8).

ENDIF.

ENDIF.

IF v_nofile = v_lines.

PERFORM create_new_file TABLES it_data

temp_dirlist

CHANGING v_crtfile.

ENDIF.

ELSE.

CLEAR wa_results.

  • Check whether the following file is the same batch first

FIND FIRST OCCURRENCE OF c_segment IN TABLE

temp_data RESULTS wa_results.

IF sy-subrc EQ '0'.

READ TABLE temp_data INTO wa_data INDEX wa_results-line.

IF sy-subrc EQ '0'.

t_payrunid = wa_data+82(6).

t_payrundt = wa_data+88(8).

  • Add more files

IF v_payrunid = t_payrunid AND

v_payrundt = t_payrundt.

LOOP AT temp_data.

APPEND temp_data TO it_data.

ENDLOOP.

REFRESH temp_data.

DELETE it_data WHERE char IS INITIAL.

  • No more files & create new batch file

IF v_nofile = v_lines.

PERFORM create_new_file TABLES it_data

temp_dirlist

CHANGING v_crtfile.

ENDIF.

ELSE.

  • Create new batch file and start another batch file

DATA: int_dirlist LIKE temp_dirlist.

int_dirlist = it_dirlist.

DELETE temp_dirlist WHERE name = int_dirlist-name.

PERFORM create_new_file TABLES it_data

temp_dirlist

CHANGING v_crtfile.

REFRESH it_data.

CLEAR wa_results.

it_data[] = temp_data[].

REFRESH temp_data.

FIND FIRST OCCURRENCE OF c_segment IN TABLE

it_data RESULTS wa_results.

IF sy-subrc EQ '0'.

READ TABLE it_data INDEX wa_results-line.

IF sy-subrc EQ '0'.

v_payrunid = it_data+82(6).

v_payrundt = it_data+88(8).

ENDIF.

ENDIF.

  • pass in temp dir list again

temp_dirlist = int_dirlist.

APPEND temp_dirlist .

IF v_nofile = v_lines.

PERFORM create_new_file TABLES it_data

temp_dirlist

CHANGING v_crtfile.

ENDIF.

ENDIF.

ENDIF.

ENDIF.

ENDIF.

ENDLOOP.

ENDFORM. " OPEN_DATASET

&----


*& Form CREATE_NEW_FILE

&----


  • text

----


  • -->P_IT_DATA text

----


FORM create_new_file TABLES vdata STRUCTURE it_data

t_list STRUCTURE temp_dirlist

USING runno.

DATA: t_file TYPE eps2filnam,

o_file TYPE eps2filnam,

plogtext(50).

runno = runno + 1.

CONCATENATE 'O_' sy-mandt '_' sy-datum '_' sy-uzeit '_' runno INTO t_file.

CONCATENATE v_outbound t_file INTO t_file.

OPEN DATASET t_file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT MESSAGE plogtext.

IF sy-subrc = 0.

LOOP AT vdata.

  • Padding for segment E1EDP02 , QUALF = 009

IF vdata+0(10) = c_segment2.

IF vdata+63(3) = c_qualf.

  • vdata+186(1) = '.'.

TRANSFER vdata-char TO t_file length '186'.

  • TRANSFER vdata-char TO t_file NO END OF LINE.

ENDIF.

ELSE.

TRANSFER vdata-char TO t_file.

ENDIF.

ENDLOOP.

CLOSE DATASET t_file.

IF sy-subrc EQ '0'.

WRITE:/ 'New file created' , t_file.

ELSE.

WRITE:/ 'New file' , t_file, 'could not be closed properly'.

ENDIF.

ELSE.

WRITE:/ 'New file' , t_file, 'could be created' .

WRITE:/ plogtext.

ENDIF.

  • Delete files in intermediate directory

LOOP AT t_list.

CONCATENATE v_dirlist t_list-name INTO o_file.

DELETE DATASET o_file.

IF sy-subrc EQ '0'.

WRITE:/ 'File' , t_list-name0(22) , 'deleted from' , v_dirlist0(47).

ELSE.

WRITE:/ 'File' , t_list-name0(22) , 'could not be deleted from' , v_dirlist0(47).

ENDIF.

ENDLOOP.

ENDFORM. " CREATE_NEW_FILE

&----


*& Form CREATE_BACKUP_FILE

&----


  • text

----


  • -->P_TEMP_DIRLIST text

  • -->P_TEMP_DATA text

----


FORM create_backup_file TABLES i_dirlist STRUCTURE temp_dirlist

i_data STRUCTURE temp_data

USING v_name.

DATA: o_file TYPE eps2filnam,

plogtext(50) TYPE c.

CONCATENATE v_archive v_name INTO o_file.

OPEN DATASET o_file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT MESSAGE plogtext.

IF sy-subrc = 0.

LOOP AT i_data.

TRANSFER i_data-char TO o_file.

ENDLOOP.

CLOSE DATASET o_file.

IF sy-subrc EQ '0'.

WRITE:/ 'File' , v_name0(22), 'backed up in directory' , v_archive0(42).

ELSE.

WRITE:/ 'File' , v_name0(22), 'could not close file during back up in directory' , v_archive0(42).

DELETE i_dirlist WHERE name = v_name.

ENDIF.

ELSE.

WRITE:/ 'File' , v_name0(22), 'could not be backed up in directory' , v_archive0(42).

DELETE i_dirlist WHERE name = v_name.

ENDIF.

ENDFORM. " CREATE_BACKUP_FILE

&----


*& Form DIRECTORY_SWITCHING

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM directory_switching .

v_dirlist+9(3) = sy-sysid.

v_outbound+9(3) = sy-sysid.

v_archive+9(3) = sy-sysid.

ENDFORM. " DIRECTORY_SWITCHING

My requirement :

ZSCB : In this Custom Transaction code..we are doing the payements and in that ZAP1(<50000) and ZAP2(>50000)

two payemnts Methods through we are apporiving payment after that it generate IDocs.

In that IDoc now we have Intermediate folder after that archive folder and Outbound folder (last) in AL11 when im checking in outbound it it is not combinig all,if i did the payment in the sametime.

Now i want to change to ZAP1 into one folder and ZAP2 into another folder under Intermediate folder.

If i did <50000 payment den it goes to the ZAP1 and same for ZAP2.

please help him..

&----


*& Report ZFII_COMBINE_IDOC_FILES

*&

&----


*&

*&

&----


REPORT zfii_combine_idoc_files LINE-SIZE 255.

******************************************************

  • Data declaration

******************************************************

CONSTANTS: c_segment(7) TYPE c VALUE 'E2IDKU3',

c_sysid LIKE sy-sysid VALUE 'DEV',

c_segment2(10) TYPE c VALUE 'E2EDP02001',

c_qualf(3) TYPE c VALUE '009'.

DATA: v_dirlist TYPE eps2filnam VALUE '/usr/sap/DEV/interface/scbpayment/intermediate/' ,

v_outbound TYPE eps2filnam VALUE '/usr/sap/DEV/interface/scbpayment/outbound/' ,

v_archive TYPE eps2filnam VALUE '/usr/sap/DEV/interface/scbpayment/archive/' .

DATA: it_dirlist LIKE eps2fili OCCURS 10 WITH HEADER LINE,

temp_dirlist LIKE eps2fili OCCURS 10 WITH HEADER LINE.

DATA: BEGIN OF it_data OCCURS 3,

char(1000) TYPE c,

END OF it_data.

DATA: wa_data LIKE LINE OF it_data.

DATA: BEGIN OF temp_data OCCURS 3,

char(1000) TYPE c,

END OF temp_data.

******************************************************

  • START-OF-SELECTION.

******************************************************

START-OF-SELECTION.

IF sy-sysid NE c_sysid.

PERFORM directory_switching.

ENDIF.

PERFORM read_dir TABLES it_dirlist USING v_dirlist.

PERFORM open_dataset.

WRITE:/ 'End of log.'.

******************************************************

  • END-OF-SELECTION.

******************************************************

END-OF-SELECTION.

******************************************************

  • Form Read Dir

******************************************************

FORM read_dir TABLES ip_dirlist STRUCTURE it_dirlist USING p_dirlist.

***

CALL FUNCTION 'EPS2_GET_DIRECTORY_LISTING'

EXPORTING

iv_dir_name = p_dirlist

  • FILE_MASK = ' '

  • IMPORTING

  • DIR_NAME =

  • FILE_COUNTER =

  • ERROR_COUNTER =

TABLES

dir_list = ip_dirlist

EXCEPTIONS

invalid_eps_subdir = 1

sapgparam_failed = 2

build_directory_failed = 3

no_authorization = 4

read_directory_failed = 5

too_many_read_errors = 6

empty_directory_list = 7

OTHERS = 8

.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ELSE.

  • for now read O_*

  • LOOP AT ip_dirlist.

  • IF ip_dirlist-name+0(2) = 'O_' .

  • ELSE.

  • DELETE ip_dirlist.

  • ENDIF.

  • ENDLOOP.

ENDIF.

ENDFORM. "read_dir

&----


*& Form OPEN_DATASET

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM open_dataset .

DATA: p_file TYPE eps2filnam,

ptext(50),

n_file TYPE i,

n_run TYPE i,

v_payrunid LIKE reguh-laufi,

v_payrundt LIKE reguh-laufd,

t_payrunid LIKE reguh-laufi,

t_payrundt LIKE reguh-laufd,

v_crtfile TYPE c,

v_nofile TYPE i,

v_lines TYPE i.

DATA: results TYPE match_result_tab,

wa_results LIKE LINE OF results.

  • Sorting so files of the same batch are sorted together

SORT it_dirlist BY name.

DESCRIBE TABLE it_dirlist LINES v_nofile.

LOOP AT it_dirlist.

v_lines = v_lines + 1.

p_file = v_dirlist.

CONCATENATE p_file it_dirlist-name INTO p_file.

OPEN DATASET p_file FOR INPUT IN TEXT MODE ENCODING DEFAULT MESSAGE ptext.

IF sy-subrc EQ '0'.

WHILE sy-subrc = 0.

READ DATASET p_file INTO temp_data-char.

APPEND temp_data.

CLEAR temp_data.

ENDWHILE.

CLOSE DATASET p_file.

IF sy-subrc EQ '0'.

WRITE:/ 'File' , it_dirlist-name0(22) , 'read from' , v_dirlist0(47).

ELSE.

WRITE:/ 'File' , it_dirlist-name0(22) , 'could not be closed, from' , v_dirlist0(47).

ENDIF.

temp_dirlist = it_dirlist.

APPEND temp_dirlist.

  • Create backup file

PERFORM create_backup_file TABLES temp_dirlist

temp_data

USING it_dirlist-name.

ELSE.

WRITE:/ 'File' , it_dirlist-name0(22) , 'could not be read from' , v_dirlist0(47).

WRITE:/ ptext.

ENDIF.

n_file = n_file + 1.

IF n_file = '1'.

it_data[] = temp_data[].

DELETE it_data WHERE char IS INITIAL.

REFRESH temp_data.

FIND FIRST OCCURRENCE OF c_segment IN TABLE

it_data RESULTS wa_results.

IF sy-subrc EQ '0'.

READ TABLE it_data INTO wa_data INDEX wa_results-line.

IF sy-subrc EQ '0'.

v_payrunid = wa_data+82(6).

v_payrundt = wa_data+88(8).

ENDIF.

ENDIF.

IF v_nofile = v_lines.

PERFORM create_new_file TABLES it_data

temp_dirlist

CHANGING v_crtfile.

ENDIF.

ELSE.

CLEAR wa_results.

  • Check whether the following file is the same batch first

FIND FIRST OCCURRENCE OF c_segment IN TABLE

temp_data RESULTS wa_results.

IF sy-subrc EQ '0'.

READ TABLE temp_data INTO wa_data INDEX wa_results-line.

IF sy-subrc EQ '0'.

t_payrunid = wa_data+82(6).

t_payrundt = wa_data+88(8).

  • Add more files

IF v_payrunid = t_payrunid AND

v_payrundt = t_payrundt.

LOOP AT temp_data.

APPEND temp_data TO it_data.

ENDLOOP.

REFRESH temp_data.

DELETE it_data WHERE char IS INITIAL.

  • No more files & create new batch file

IF v_nofile = v_lines.

PERFORM create_new_file TABLES it_data

temp_dirlist

CHANGING v_crtfile.

ENDIF.

ELSE.

  • Create new batch file and start another batch file

DATA: int_dirlist LIKE temp_dirlist.

int_dirlist = it_dirlist.

DELETE temp_dirlist WHERE name = int_dirlist-name.

PERFORM create_new_file TABLES it_data

temp_dirlist

CHANGING v_crtfile.

REFRESH it_data.

CLEAR wa_results.

it_data[] = temp_data[].

REFRESH temp_data.

FIND FIRST OCCURRENCE OF c_segment IN TABLE

it_data RESULTS wa_results.

IF sy-subrc EQ '0'.

READ TABLE it_data INDEX wa_results-line.

IF sy-subrc EQ '0'.

v_payrunid = it_data+82(6).

v_payrundt = it_data+88(8).

ENDIF.

ENDIF.

  • pass in temp dir list again

temp_dirlist = int_dirlist.

APPEND temp_dirlist .

IF v_nofile = v_lines.

PERFORM create_new_file TABLES it_data

temp_dirlist

CHANGING v_crtfile.

ENDIF.

ENDIF.

ENDIF.

ENDIF.

ENDIF.

ENDLOOP.

ENDFORM. " OPEN_DATASET

&----


*& Form CREATE_NEW_FILE

&----


  • text

----


  • -->P_IT_DATA text

----


FORM create_new_file TABLES vdata STRUCTURE it_data

t_list STRUCTURE temp_dirlist

USING runno.

DATA: t_file TYPE eps2filnam,

o_file TYPE eps2filnam,

plogtext(50).

runno = runno + 1.

CONCATENATE 'O_' sy-mandt '_' sy-datum '_' sy-uzeit '_' runno INTO t_file.

CONCATENATE v_outbound t_file INTO t_file.

OPEN DATASET t_file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT MESSAGE plogtext.

IF sy-subrc = 0.

LOOP AT vdata.

  • Padding for segment E1EDP02 , QUALF = 009

IF vdata+0(10) = c_segment2.

IF vdata+63(3) = c_qualf.

  • vdata+186(1) = '.'.

TRANSFER vdata-char TO t_file length '186'.

  • TRANSFER vdata-char TO t_file NO END OF LINE.

ENDIF.

ELSE.

TRANSFER vdata-char TO t_file.

ENDIF.

ENDLOOP.

CLOSE DATASET t_file.

IF sy-subrc EQ '0'.

WRITE:/ 'New file created' , t_file.

ELSE.

WRITE:/ 'New file' , t_file, 'could not be closed properly'.

ENDIF.

ELSE.

WRITE:/ 'New file' , t_file, 'could be created' .

WRITE:/ plogtext.

ENDIF.

  • Delete files in intermediate directory

LOOP AT t_list.

CONCATENATE v_dirlist t_list-name INTO o_file.

DELETE DATASET o_file.

IF sy-subrc EQ '0'.

WRITE:/ 'File' , t_list-name0(22) , 'deleted from' , v_dirlist0(47).

ELSE.

WRITE:/ 'File' , t_list-name0(22) , 'could not be deleted from' , v_dirlist0(47).

ENDIF.

ENDLOOP.

ENDFORM. " CREATE_NEW_FILE

&----


*& Form CREATE_BACKUP_FILE

&----


  • text

----


  • -->P_TEMP_DIRLIST text

  • -->P_TEMP_DATA text

----


FORM create_backup_file TABLES i_dirlist STRUCTURE temp_dirlist

i_data STRUCTURE temp_data

USING v_name.

DATA: o_file TYPE eps2filnam,

plogtext(50) TYPE c.

CONCATENATE v_archive v_name INTO o_file.

OPEN DATASET o_file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT MESSAGE plogtext.

IF sy-subrc = 0.

LOOP AT i_data.

TRANSFER i_data-char TO o_file.

ENDLOOP.

CLOSE DATASET o_file.

IF sy-subrc EQ '0'.

WRITE:/ 'File' , v_name0(22), 'backed up in directory' , v_archive0(42).

ELSE.

WRITE:/ 'File' , v_name0(22), 'could not close file during back up in directory' , v_archive0(42).

DELETE i_dirlist WHERE name = v_name.

ENDIF.

ELSE.

WRITE:/ 'File' , v_name0(22), 'could not be backed up in directory' , v_archive0(42).

DELETE i_dirlist WHERE name = v_name.

ENDIF.

ENDFORM. " CREATE_BACKUP_FILE

&----


*& Form DIRECTORY_SWITCHING

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM directory_switching .

v_dirlist+9(3) = sy-sysid.

v_outbound+9(3) = sy-sysid.

v_archive+9(3) = sy-sysid.

ENDFORM. " DIRECTORY_SWITCHING

1 REPLY 1
Read only

Former Member
0 Likes
415

ZSCB : In this Custom Transaction code..

we are doing the payements and in that ZAP1(<50000) and ZAP2(>50000) two payemnts Methods through we are apporiving payment after that it generate IDocs.

In that IDoc now we have Intermediate folder after that archive folder and Outbound folder (last) in AL11

when im checking in outbound it it is not combinig all,if i did the payment in the sametime.

Now i want to change to ZAP1 into one folder and ZAP2 into another folder under Intermediate folder.

If i did <50000 payment den it goes to the ZAP1 and same for ZAP2. please help him.. \

I need to create folder in intermedaite Path in al11 ZAP1 & ZAP2 , i created with help of Basis.

But where should i change in the program.

please help me.