Registration

Dear SAP Community Member,
In order to fully benefit from what the SAP Community has to offer, please register at:
http://scn.sap.com
Thank you,
The SAP Community team.
Skip to end of metadata
Go to start of metadata

REPORT ZFI_PA_SAP_INTERFACE.*&---------------------------------------------------------------------*

*& TABLES

*&---------------------------------------------------------------------*tables: zfi_pa_sap_input.**&---------------------------------------------------------------------

**& TYPES

**&---------------------------------------------------------------------type-pools: slis, abap.

types: begin of t_match,

bukrs type bukrs,

PYMT_REBZG(18) type c,

PYMT_belnr(18) type c,

SGTXT type SGTXT,

PYMT_HO_KUNNR(10) type c,

INV_CO_CD type bukrs,

inv_REBZG(18) type c,

inv_belnr(18) type c,

inv_HO_KUNNR(10) type c,

dmbtr(12) type c,

CURR_FLAG(1) type c,

NO_SMALLS_CLEAR(1) type c,

PA_USER_ID(7) type c,

CHQ_REC_YYMMDD(6) type c,

RES_INV_AMT_TXT(50) type c,

PA_CREATE_DT_TM(14) type c,

ELEC_PAY_IND(2) type c,

end of t_match,

begin of t_cntl,

date(8) type c,

time(6) type c,

cnt(10) type c,

amount1(13) type c,

amount2(13) type c,

amount3(13) type c,

fname(50) type c,

end of t_cntl.

**&---------------------------------------------------------------------

**& CONSTANTS

**&---------------------------------------------------------------------

constants: c_yp type blart value 'YP',

c_yq type blart value 'YQ',

c_4 type mansp value '4',

c_6 type mansp value '6',

c_p type mansp value 'P',

c_c type mansp value 'C',

c_u type mansp value 'U',

c_y type mansp value 'Y',

c_05 type bschl value '05',

c_15 type bschl value '15',

c_payment(8) value 'PAYMENT ',

c_1000 type bukrs value '1000',

c_3000 type bukrs value '3000',

c_4000 type bukrs value '4000',

c_cad type waers value 'CAD',

c_usd type waers value 'USD',

c_cpr(3) type c value 'CPR',

c_object LIKE inri-object VALUE 'ZAR_IFACE',

c_subobject LIKE inri-subobject VALUE 'PAMP',

c_direction VALUE 'I',

c_nrrangenr LIKE inri-nrrangenr VALUE '01',

c_zero type dmbtr value 0,

c_input type fileintern value 'Z_ARCH_PA_SAP_INPUT',

c_processed type fileintern

value 'Z_ARCH_PA_SAP_PROCESSED'.
*&---------------------------------------------------------------------*

*& GLOBAL TABLES/STRUCTURES

*&---------------------------------------------------------------------*data: gt_pa_data type table of zfi_pa_match_input,

gt_match type table of zfi_pa_sap_input,

gt_match type table of t_match,

begin of gt_oi_extr occurs 0.

include structure zfi_arch_oi_extr.

data: transfer_kunnr type kunnr,

dunning_waers type waers,

error type c,

end of gt_oi_extr,

bdcdata like bdcdata occurs 0 with header line,

begin of gt_alv_data occurs 0,

p_bukrs like bkpf-bukrs,

p_kunnr like kna1-kunnr,

payment like bseg-zuonr,

i_bukrs like bkpf-bukrs,

i_kunnr like kna1-kunnr,

invoice like bseg-zuonr,

wrbtr like bseg-wrbtr,

dmbtr like bseg-dmbtr,

userid like sy-uname,

proftxt like twupt-proftxt,

error like bdcmsgcoll-msgtyp,

end of gt_alv_data,

gt_cntl type table of t_cntl,

gt_restart type table of zfi_pa_sap_input.*&---------------------------------------------------------------------*

*& GLOBAL DATA DECLARATIONS

*&---------------------------------------------------------------------*data: gs_match type t_match,

gs_oi_extr like line of gt_oi_extr,

gs_processed type zfi_pa_sap_input,

g_total_amount type wrbtr,

g_credits type wrbtr,

g_debits type wrbtr,

g_subrc type sy-subrc,

gs_cntl type t_cntl,

g_unix_filename type char128,

begin of g_applog_key,

object type balobj_d,

subobject type balsubobj,

extnumber type balnrext,

end of g_applog_key,

g_context type bal_s_cont,

g_processed_records type i,

g_record_count(6) type n,

g_email type c,

gs_zar_iface_cntl LIKE zar_iface_cntl,

g_batch_no type zar_batch_no,

g_lines type i,

g_file_input type char128,

g_file_cntl type char128,

g_file_processed type char128,

g_file_processed_cntl type char128.

*--------------------------------

* ALV Structures

*--------------------------------

data:

gt_fieldcat type slis_t_fieldcat_alv,

gs_fieldcat like line of gt_fieldcat,

gs_alv_events_tab type slis_t_event,

gs_alv_event_exit_tab type slis_t_event_exit,

gs_alv_list_comments_tab type slis_t_listheader,

gs_alv_sortcat_tab type slis_t_sortinfo_alv,

gs_alv_excluding_tab type slis_t_extab,

gs_print type slis_print_alv,

gs_alv_layout type slis_layout_alv,

g_replevel type i value 1.

*&---------------------------------------------------------------------*

*& selection screen

*&---------------------------------------------------------------------*

selection-screen begin of block bl1 with frame title text-001.

parameters: p_date type sy-datum default sy-datum,

p_mode like CTU_PARAMS-DISMODE default 'N'.

selection-screen begin of block bl2 with frame title text-002.

parameters: p_rad3 radiobutton group r1 default 'X',

p_fparm1 type char20 lower case,

p_fparm2 type char20 lower case,

p_rad1 radiobutton group r1,

p_usctl as checkbox,

p_pcfile type localfile," obligatory,

p_cntl type localfile, "obligatory,

p_rad2 radiobutton group r1,

p_apfile like path-pathextern,

p_apctl like path-pathextern,

p_move like path-pathextern,

p_mvctl like path-pathextern.

selection-screen end of block bl2.

selection-screen begin of block bl3 with frame title text-013.

parameters: p_rest type c as checkbox,

p_cpud like sy-datum default sy-datum,

p_fnum(2) type n no-display.

selection-screen end of block bl3.

parameters: p_email like sy-uname default sy-uname.

selection-screen end of block bl1.

selection-screen skip 2.

*&---------------------------------------------------------------------*

*& AT selection screen

*&---------------------------------------------------------------------*

at selection-screen on value-request for p_pcfile.

perform choose_file changing p_pcfile.

at selection-screen on value-request for p_cntl.

perform choose_file changing p_cntl.

at selection-screen.

if p_rad3 = abap_true.

if p_fparm1 is initial.

message s899(fi) with text-015.

g_subrc = 4.

endif.

elseif p_rad1 = abap_true.

if p_pcfile is initial.

message s899(fi) with text-015.

g_subrc = 4.

endif.

else.

if p_apfile is initial.

message s899(fi) with text-015.

g_subrc = 4.

endif.

endif.

at selection-screen on p_usctl.

if not p_usctl is initial.

if p_rad1 = abap_true.

if p_cntl is initial.

message s899(fi) with text-019.

g_subrc = 4.

endif.

elseif p_rad2 = abap_true.

if p_apctl is initial.

message s899(fi) with text-019.

g_subrc = 4.

endif.

else.

if p_fparm2 is initial.

message s899(fi) with text-019.

g_subrc = 4.

endif.

endif.

endif.

*&---------------------------------------------------------------------*

*& Start of Selection

*&---------------------------------------------------------------------*

start-of-selection.

check g_subrc is initial.

if p_fnum is initial.

p_fnum = 01.

endif.

if p_rest = abap_true.

select * into table gt_restart

from zfi_pa_sap_input

where file_count = p_fnum.

describe table gt_restart lines g_processed_records.

endif.

select single * into gs_zar_iface_cntl

from zar_iface_cntl

where iface_id = c_subobject

and batch_no = (

select max( batch_no ) "into g_batch_no

from zar_iface_cntl

where iface_id = c_subobject ).

if p_rad3 = abap_true.

perform get_filenames.

endif.

* Get the PA data

perform upload_pa_files.

perform verify_controls changing g_subrc.

check g_subrc is initial.

perform retrieve_oi_extr.

*&---------------------------------------------------------------------*

*& End of Selection

*&---------------------------------------------------------------------*

end-of-selection.

check g_subrc is initial.

perform process_pa_input.

if not gt_match is initial.

perform set_dunning_blocks.

delete from zfi_pa_sap_input

where file_count = p_fnum.

if sy-subrc = 0.

commit work.

endif.

if g_email = abap_true.

perform send_email.

endif.

if p_rad1 = abap_false.

perform move_file.

endif.

perform call_alv.

else.

write : / text-022.

endif.

perform create_control_file.

*&---------------------------------------------------------------------*

*& FORMS

*&---------------------------------------------------------------------*

*&---------------------------------------------------------------------*

*& Form choose_file

*&---------------------------------------------------------------------*

* text

*----------------------------------------------------------------------*

* <--P_P_PCFILE text

*----------------------------------------------------------------------*

FORM choose_file CHANGING f_PCFILE.

CALL FUNCTION 'WS_FILENAME_GET'

EXPORTING

MASK = '.,..'

IMPORTING

FILENAME = f_pcfile

EXCEPTIONS

OTHERS = 0.

ENDFORM. " choose_file

*&---------------------------------------------------------------------*

*& Form upload_pa_files

*&---------------------------------------------------------------------*

* text

*----------------------------------------------------------------------*

* --> p1 text

* <-- p2 text

*----------------------------------------------------------------------*

FORM upload_pa_files.

data: l_pcfile type string,

ls_pa_data type zfi_pa_match_input,

ls_match type t_match,

l_belnr(11) type c,

* l_belnr type belnr_d,

l_line type zfi_pa_match_input,

l_len type i.

if p_rad1 = 'X'.

l_pcfile = p_pcfile.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

FILENAME = l_pcfile

TABLES

DATA_TAB = gt_pa_data

EXCEPTIONS

OTHERS = 4.

IF SY-SUBRC <> 0.

set parameter id 'MESSAGE_DISPLAY_TYPE' field 'E'.

message s899(fi) with 'Cannot read file' l_pcfile.

stop.

ENDIF.

if not p_usctl is initial.

l_pcfile = p_cntl.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

FILENAME = l_pcfile

TABLES

DATA_TAB = gt_cntl

EXCEPTIONS

OTHERS = 4.

IF SY-SUBRC <> 0.

set parameter id 'MESSAGE_DISPLAY_TYPE' field 'E'.

message s899(fi) with 'Cannot read file' l_pcfile.

g_subrc = 4.

ENDIF.

endif.

else.

if p_rad3 = abap_true.

g_unix_filename = g_file_input.

else.

g_unix_filename = p_apfile.

endif.

catch system-exceptions open_dataset_no_authority = 1

dataset_cant_open = 2

dataset_cant_close = 3.

open dataset g_unix_filename for input in text mode.

do.

read dataset g_unix_filename into l_line.

if sy-subrc ne 0.

exit.

endif.

* Leave all the blank lines and append only waybill lines

if l_line co ' '.

continue.

else.

append l_line to gt_pa_data.

endif.

enddo.

close dataset g_unix_filename.

endcatch.

case sy-subrc.

when 1. "No authority

set parameter id 'MESSAGE_DISPLAY_TYPE' field 'E'.

message i050(zarch_wb) with g_unix_filename.

* No authority to open file &1

g_subrc = 4.

when 2. "Can't open

set parameter id 'MESSAGE_DISPLAY_TYPE' field 'E'.

message i051(zarch_wb) with g_unix_filename.

* Cannot open file &1

g_subrc = 4.

when 3. "Can't close

set parameter id 'MESSAGE_DISPLAY_TYPE' field 'E'.

message i052(zarch_wb) with g_unix_filename.

* Cannot close file &1

g_subrc = 4.

endcase.

if not p_usctl is initial.

if p_rad3 = abap_true.

g_unix_filename = g_file_cntl.

else.

g_unix_filename = p_apctl.

endif.

catch system-exceptions open_dataset_no_authority = 1

dataset_cant_open = 2

dataset_cant_close = 3.

open dataset g_unix_filename for input in text mode.

do.

read dataset g_unix_filename into gs_cntl.

if sy-subrc ne 0.

exit.

endif.

* Leave all the blank lines and append only waybill lines

if gs_cntl co ' '.

continue.

else.

append gs_cntl to gt_cntl.

endif.

enddo.

close dataset g_unix_filename.

endcatch.

case sy-subrc.

when 1. "No authority

set parameter id 'MESSAGE_DISPLAY_TYPE' field 'E'.

message i050(zarch_wb) with g_unix_filename.

* No authority to open file &1

g_subrc = 4.

when 2. "Can't open

set parameter id 'MESSAGE_DISPLAY_TYPE' field 'E'.

message i051(zarch_wb) with g_unix_filename.

* Cannot open file &1

g_subrc = 4.

when 3. "Can't close

set parameter id 'MESSAGE_DISPLAY_TYPE' field 'E'.

message i052(zarch_wb) with g_unix_filename.

* Cannot close file &1

g_subrc = 4.

endcase.

endif.

endif.

loop at gt_pa_data into ls_pa_data.

if ls_pa_data-dmbtr > c_zero.

add ls_pa_data-dmbtr to g_credits.

else.

add ls_pa_data-dmbtr to g_debits.

endif.

move-corresponding ls_pa_data to ls_match.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING

INPUT = ls_pa_data-pymt_ho_kunnr

IMPORTING

OUTPUT = ls_match-pymt_ho_kunnr.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING

INPUT = ls_pa_data-inv_ho_kunnr

IMPORTING

OUTPUT = ls_match-inv_ho_kunnr.

l_len = strlen( ls_pa_data-inv_rebzg ).

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING

INPUT = ls_pa_data-inv_rebzg

IMPORTING

OUTPUT = l_belnr.

ls_pa_data-inv_rebzg = l_belnr.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING

INPUT = ls_pa_data-inv_belnr

IMPORTING

OUTPUT = l_belnr.

ls_pa_data-inv_belnr = l_belnr.

case l_len.

when 11.

ls_match-inv_belnr = ls_pa_data-inv_belnr.

ls_match-inv_rebzg = ls_pa_data-inv_rebzg.

when others.

ls_match-inv_belnr = ls_pa_data-inv_belnr+1.

ls_match-inv_rebzg = ls_pa_data-inv_rebzg+1.

endcase.

append ls_match to gt_match.

endloop.

g_total_amount = ( g_debits * -1 ) + g_credits.

ENDFORM. " upload_pa_files

*&---------------------------------------------------------------------*

*& Form retrieve_oi_extr

*&---------------------------------------------------------------------*

* text

*----------------------------------------------------------------------*

* --> p1 text

* <-- p2 text

*----------------------------------------------------------------------*

FORM retrieve_oi_extr.

check not gt_match is initial.

select kunnr zuonr bukrs rectype bldat waers xblnr sgtxt xref1

xref2 xref3 xref1_hd outs_cad outs_usd filkd xrate_cad2usd

xrate_usd2cad orig_cad orig_usd zzcpr01 zzcpr02 zzcpr03 zzcpr04

blart bktxt

into corresponding fields of table gt_oi_extr

from zfi_arch_oi_extr

for all entries in gt_match

where zuonr = gt_match-pymt_rebzg.

select kunnr zuonr bukrs rectype bldat waers xblnr sgtxt xref1

xref2 xref3 xref1_hd outs_cad outs_usd filkd xrate_cad2usd

xrate_usd2cad orig_cad orig_usd zzcpr01 zzcpr02 zzcpr03 zzcpr04

blart bktxt

appending corresponding fields of table gt_oi_extr

from zfi_arch_oi_extr

for all entries in gt_match

where zuonr = gt_match-inv_rebzg.

if gt_oi_extr[] is initial.

message s899(fi) with text-016.

g_subrc = 4.

endif.

ENDFORM. " retrieve_oi_extr

*&---------------------------------------------------------------------*

*& Form process_pa_input

*&---------------------------------------------------------------------*

* text

*----------------------------------------------------------------------*

* --> p1 text

* <-- p2 text

*----------------------------------------------------------------------*

FORM process_pa_input.

data: ls_match type t_match,

ls_inv_rec like line of gt_oi_extr,

ls_pay_rec like line of gt_oi_extr,

lt_messtab like bdcmsgcoll occurs 0 with header line,

l_blart type blart,

l_kursfc(10) type c,

l_kursf type kursf,

l_arch type zvbakarch,

l_bktxt type bktxt,

l_payment_waers type waers,

l_dmbtr type dmbtr,

l_wrbtr type wrbtr,

l_dmbtrc(13) type c,

l_wrbtrc(13) type c,

l_payment_amtc(13) type c,

l_amt type dmbtr,

l_payment_amt like bseg-pyamt,

l_msgnr(3) type n,

l_pay_exch_amt like bseg-pyamt,

l_subrc like sy-subrc,

ls_restart type zfi_pa_sap_input,

l_restart_complete type c,

l_insert_restart_record_only type c,

l_open,

l_negative.

data: ctumode like ctu_params-dismode,

cupdate like ctu_params-updmode value 'S'.

ctumode = p_mode.

loop at gt_match into ls_match.

clear l_bktxt.

concatenate ls_match-pa_user_id ls_match-pa_create_dt_tm

into l_bktxt.

read table gt_oi_extr into ls_pay_rec

with key zuonr = ls_match-pymt_belnr.

if sy-subrc <> 0.

perform write_applog using ls_match-pymt_belnr

'E' 'ZFI_ISS' '000'

text-017

' '

' '

' '.

g_email = abap_true.

gt_alv_data-payment = ls_match-pymt_belnr.

gt_alv_data-invoice = ls_match-inv_belnr.

gt_alv_data-p_bukrs = ls_match-bukrs.

gt_alv_data-i_bukrs = ls_match-inv_co_cd.

gt_alv_data-p_kunnr = ls_match-pymt_ho_kunnr.

gt_alv_data-i_kunnr = ls_match-inv_ho_kunnr.

gt_alv_data-userid = ls_match-pa_user_id.

gt_alv_data-wrbtr = ls_match-dmbtr.

gt_alv_data-proftxt = text-017.

append gt_alv_data.

continue.

endif.

read table gt_oi_extr into ls_inv_rec

with key zuonr = ls_match-inv_belnr.

if sy-subrc <> 0.

perform write_applog using ls_match-inv_belnr

'E' 'ZFI_ISS' '000'

text-018

' '

' '

' '.

g_email = abap_true.

gt_alv_data-payment = ls_match-pymt_belnr.

gt_alv_data-invoice = ls_match-inv_belnr.

gt_alv_data-p_bukrs = ls_match-bukrs.

gt_alv_data-i_bukrs = ls_match-inv_co_cd.

gt_alv_data-p_kunnr = ls_match-pymt_ho_kunnr.

gt_alv_data-i_kunnr = ls_match-inv_ho_kunnr.

gt_alv_data-userid = ls_match-pa_user_id.

gt_alv_data-wrbtr = ls_match-dmbtr.

gt_alv_data-proftxt = text-018.

append gt_alv_data.

continue.

endif.

add 1 to g_record_count.

* Restart matching if required

if p_rest = abap_true.

if l_restart_complete = abap_false.

read table gt_restart into ls_restart

with key file_count = p_fnum

rec_count = g_record_count

transporting dunning_waers outs_cad

outs_usd transfer_kunnr.

* These records have been successfully processed since they

* are in the restart file and there were subsequent records

* inserted succesfully after. So just move the outstanding

* amounts and dummy customer if necessary

if g_record_count < g_processed_records.

ls_inv_rec-outs_cad = ls_restart-outs_cad .

ls_inv_rec-outs_usd = ls_restart-outs_usd .

ls_inv_rec-dunning_waers = ls_restart-dunning_waers.

modify gt_oi_extr from ls_inv_rec

transporting dunning_waers

outs_cad

outs_usd

where zuonr = ls_inv_rec-zuonr.

if not ls_restart-transfer_kunnr is initial.

ls_pay_rec-transfer_kunnr = ls_restart-transfer_kunnr.

modify gt_oi_extr from ls_pay_rec

transporting transfer_kunnr

where zuonr = ls_pay_rec-zuonr.

endif.

continue.

* This record was also inserted successfully, but is it the first

* half of a 'move dummy' pair? If it is the first doc of the dummy

* customer, the transfer kunnr should be populated.

elseif g_record_count = g_processed_records.

if not ls_restart-transfer_kunnr is initial.

if not ls_restart-flag is initial.

ls_inv_rec-outs_cad = ls_restart-outs_cad .

ls_inv_rec-outs_usd = ls_restart-outs_usd .

ls_inv_rec-dunning_waers = ls_restart-dunning_waers.

modify gt_oi_extr from ls_inv_rec

transporting dunning_waers

outs_cad

outs_usd

where zuonr = ls_inv_rec-zuonr.

ls_pay_rec-transfer_kunnr = ls_restart-transfer_kunnr.

modify gt_oi_extr from ls_pay_rec

transporting transfer_kunnr

where zuonr = ls_pay_rec-zuonr.

continue.

else.

* Did we create a payment document but fail to update the

* restart record?

select count( * )

from bkpf

where xblnr = ls_pay_rec-xblnr

and cpudt = p_cpud

and blart in (c_yq, c_yp)

and bktxt = l_bktxt.

* If dbcnt = 1, we did create the document so go to the next. If we

* did not create the document, we set the restart flag to compete

* and continue to process the remainder of the PA file

if sy-dbcnt = 1.

ls_inv_rec-outs_cad = ls_restart-outs_cad .

ls_inv_rec-outs_usd = ls_restart-outs_usd .

ls_inv_rec-dunning_waers = ls_restart-dunning_waers.

modify gt_oi_extr from ls_inv_rec

transporting dunning_waers

outs_cad

outs_usd

where zuonr = ls_inv_rec-zuonr.

ls_pay_rec-transfer_kunnr = ls_restart-transfer_kunnr.

modify gt_oi_extr from ls_pay_rec

transporting transfer_kunnr

where zuonr = ls_pay_rec-zuonr.

clear gs_processed.

move-corresponding ls_match to gs_processed.

move p_fnum to gs_processed-file_count.

gs_processed-rec_count = g_record_count.

gs_processed-flag = abap_true.

gs_processed-transfer_kunnr = ls_match-pymt_ho_kunnr.

CALL FUNCTION 'ZFI_INSERT_PA_SAP_INPUT'

EXPORTING

I_PROCESSED = gs_processed

IMPORTING

E_SUBRC = l_subrc.

if sy-subrc = 0.

commit work.

endif.

l_restart_complete = abap_true.

continue.

else.

ls_pay_rec-transfer_kunnr = ls_restart-transfer_kunnr.

l_restart_complete = abap_true.

endif.

endif.

else.

ls_inv_rec-outs_cad = ls_restart-outs_cad .

ls_inv_rec-outs_usd = ls_restart-outs_usd .

ls_inv_rec-dunning_waers = ls_restart-dunning_waers.

modify gt_oi_extr from ls_inv_rec

transporting dunning_waers

outs_cad

outs_usd

where zuonr = ls_inv_rec-zuonr.

continue.

endif.

elseif g_record_count > g_processed_records.

* We've checked all the restart records and they are fine. Did

* we create a document on the last record but fail to insert into

* the restart table?

* Is it a dummy move record?

if ls_match-pymt_ho_kunnr <> ls_pay_rec-kunnr and

ls_pay_rec-outs_cad = ls_pay_rec-orig_cad and

ls_pay_rec-outs_usd = ls_pay_rec-orig_usd.

select count( * )

from bkpf

where xblnr = ls_pay_rec-xblnr

and cpudt = p_cpud

and blart = ls_pay_rec-blart

and bktxt = ls_pay_rec-bktxt.

if sy-dbcnt = 1.

ls_pay_rec-transfer_kunnr = ls_match-pymt_ho_kunnr.

modify gt_oi_extr from ls_pay_rec

transporting transfer_kunnr

where zuonr = ls_pay_rec-zuonr.

clear gs_processed.

move-corresponding ls_match to gs_processed.

move p_fnum to gs_processed-file_count.

gs_processed-transfer_kunnr = ls_match-pymt_ho_kunnr.

gs_processed-rec_count = g_record_count.

gs_processed-flag = abap_true.

CALL FUNCTION 'ZFI_INSERT_PA_SAP_INPUT'

EXPORTING

I_PROCESSED = gs_processed

IMPORTING

E_SUBRC = l_subrc.

if sy-subrc = 0.

commit work.

endif.

l_restart_complete = abap_true.

else.

l_restart_complete = abap_true.

endif.

else.

select count( * )

from bkpf

where xblnr = ls_pay_rec-xblnr

and cpudt = p_cpud

and blart in (c_yq, c_yp)

and bktxt = l_bktxt.

if sy-dbcnt = 1.

l_restart_complete = abap_true.

l_insert_restart_record_only = abap_true.

else.

l_restart_complete = abap_true.

endif.

endif.

endif.

endif.

endif.

* End of Restart logic

* Move 'dummy' customer amount if required

if ls_match-pymt_ho_kunnr <> ls_pay_rec-kunnr and

ls_pay_rec-outs_cad = ls_pay_rec-orig_cad and

ls_pay_rec-outs_usd = ls_pay_rec-orig_usd.

if ls_pay_rec-transfer_kunnr is initial.

clear l_subrc.

perform move_from_dummy using ls_match

ls_inv_rec

ls_pay_rec

changing l_subrc.

if l_subrc is initial.

ls_pay_rec-transfer_kunnr = ls_match-pymt_ho_kunnr.

modify gt_oi_extr from ls_pay_rec

transporting transfer_kunnr

where zuonr = ls_pay_rec-zuonr.

else.

ls_inv_rec-error = abap_true.

modify gt_oi_extr from ls_inv_rec

transporting error

where zuonr = ls_inv_rec-zuonr.

continue.

endif.

* else. "dc

* ls_pay_rec-kunnr = ls_pay_rec-transfer_kunnr. "dc

endif.

endif.

if not ( ls_pay_rec-transfer_kunnr is initial ). "dc

ls_pay_rec-kunnr = ls_pay_rec-transfer_kunnr. "dc

endif. "dc

clear: bdcdata, l_blart, l_kursfc, l_dmbtr,

l_payment_waers, l_wrbtr, gt_alv_data.

refresh: bdcdata.

gt_alv_data-payment = ls_match-pymt_belnr.

gt_alv_data-invoice = ls_match-inv_belnr.

gt_alv_data-p_bukrs = ls_pay_rec-bukrs.

gt_alv_data-i_bukrs = ls_inv_rec-bukrs.

gt_alv_data-p_kunnr = ls_pay_rec-kunnr.

gt_alv_data-i_kunnr = ls_inv_rec-kunnr.

gt_alv_data-userid = ls_match-pa_user_id.

clear l_negative.

if ls_match-dmbtr < 0.

l_negative = abap_true.

ls_match-dmbtr = ls_match-dmbtr * -1.

endif.

* Figure out currencies and amounts

if ls_pay_rec-waers = c_cad.

l_blart = c_yp.

l_payment_waers = c_usd.

l_kursfc = ls_inv_rec-xrate_cad2usd. "dc

if ls_match-curr_flag = 'C'.

l_amt = ls_match-dmbtr. "dc

l_payment_amt = ls_match-dmbtr * ls_inv_rec-xrate_cad2usd. "dc

l_wrbtr = l_amt. "dc

l_pay_exch_amt = l_wrbtr * ls_pay_rec-xrate_cad2usd.

else.

l_amt = ls_match-dmbtr * ls_inv_rec-xrate_usd2cad. "dc

l_payment_amt = ls_match-dmbtr. "dc

l_wrbtr = l_amt. "dc

l_pay_exch_amt = l_wrbtr * ls_pay_rec-xrate_cad2usd.

endif.

if ls_inv_rec-waers = c_cad. "dc

ls_inv_rec-dunning_waers = c_cad.

if l_negative = abap_true.

ls_inv_rec-outs_cad = ls_inv_rec-outs_cad + l_wrbtr.

else.

ls_inv_rec-outs_cad = ls_inv_rec-outs_cad - l_wrbtr.

endif.

else. "dc

ls_inv_rec-dunning_waers = c_usd. "dc

if l_negative = abap_true.

ls_inv_rec-outs_usd = ls_inv_rec-outs_usd + l_payment_amt.

else.

ls_inv_rec-outs_usd = ls_inv_rec-outs_usd - l_payment_amt. "dc

endif.

endif. "dc

else.

l_blart = c_yq.

l_payment_waers = c_cad.

l_kursfc = ls_inv_rec-xrate_usd2cad. "dc

if ls_match-curr_flag = 'C'.

l_amt = ls_match-dmbtr * ls_inv_rec-xrate_cad2usd. "dc

l_payment_amt = ls_match-dmbtr. "dc

l_wrbtr = l_amt. "dc

l_pay_exch_amt = l_wrbtr * ls_pay_rec-xrate_usd2cad.

else.

l_amt = ls_match-dmbtr. "dc

l_payment_amt = ls_match-dmbtr * ls_inv_rec-xrate_usd2cad. "dc

l_wrbtr = l_amt. "dc

l_pay_exch_amt = l_wrbtr * ls_pay_rec-xrate_usd2cad.

endif.

if ls_inv_rec-waers = c_cad. "dc

ls_inv_rec-outs_cad = ls_inv_rec-outs_cad - l_payment_amt. "dc

ls_inv_rec-dunning_waers = c_cad. "dc

else. "dc

ls_inv_rec-outs_usd = ls_inv_rec-outs_usd - l_wrbtr.

ls_inv_rec-dunning_waers = c_usd.

endif. "dc

endif.

* Make sure payment amount isn't too long for the screen.

l_wrbtrc = l_wrbtr.

* Create the document to reduce the invoice

*

perform bdc_dynpro using 'SAPMF05A' '0100'.

perform bdc_field using: 'BDC_CURSOR' 'RF05A-NEWKO',

'BKPF-BLDAT' ls_pay_rec-bldat.

perform bdc_field using 'BKPF-BLART' l_blart.

perform bdc_field using 'BKPF-BUKRS' ls_pay_rec-bukrs.

clear l_open.

perform check_period using ls_pay_rec-bldat changing l_open.

if l_open is initial.

perform bdc_field using 'BKPF-BUDAT' ls_pay_rec-bldat.

else.

perform bdc_field using 'BKPF-BUDAT' p_date.

endif.

perform bdc_field using 'BKPF-WAERS' ls_pay_rec-waers.

perform bdc_field using 'BKPF-XBLNR' ls_pay_rec-xblnr.

perform bdc_field using 'BKPF-BKTXT' l_bktxt.

if l_negative = abap_false.

perform bdc_field using 'RF05A-NEWBS' c_05.

else.

perform bdc_field using 'RF05A-NEWBS' c_15.

endif.

perform bdc_field using 'RF05A-NEWKO' ls_pay_rec-kunnr.

perform bdc_field using 'BDC_OKCODE' '/00'.

perform bdc_dynpro using 'SAPMF05A' '0301'.

perform bdc_field using 'BDC_CURSOR' 'RF05A-NEWKO'.

perform bdc_field using 'BSEG-WRBTR' l_wrbtrc.

if ( ls_pay_rec-waers = c_cad and ( ls_pay_rec-bukrs = "dc

c_3000 or ls_pay_rec-bukrs = c_4000 ) ) OR "dc

( ls_pay_rec-waers = c_usd and ls_pay_rec-bukrs = c_1000 ). "dc

l_dmbtrc = l_payment_amt. "dc

perform bdc_field using 'BSEG-DMBTR' l_dmbtrc. "dc

endif. "dc

perform bdc_field using 'BSEG-PYCUR' l_payment_waers.

l_payment_amtc = l_pay_exch_amt.

perform bdc_field using 'BSEG-PYAMT' l_payment_amtc.

perform bdc_field using 'BSEG-KIDNO' ls_inv_rec-zuonr. "dc

perform bdc_field using 'BSEG-ZUONR' ls_pay_rec-zuonr.

perform bdc_field using 'BSEG-SGTXT' ls_match-sgtxt.

perform bdc_field using 'BDC_OKCODE' '=ZK'.

perform bdc_dynpro using 'SAPMF05A' '0331'.

perform bdc_field using 'BSEG-XREF1' ls_pay_rec-xref1.

perform bdc_field using 'BSEG-XREF2' ls_pay_rec-xref2.

perform bdc_field using 'BSEG-XREF3' ls_pay_rec-xref3.

if l_negative = abap_false.

perform bdc_field using 'RF05A-NEWBS' c_15.

else.

perform bdc_field using 'RF05A-NEWBS' c_05.

endif.

*Begin of INSERT -SD0K954486

*If Branch account number is initial, pass HO (Customer no) as account

*number

if ls_inv_rec-filkd is initial.

perform bdc_field using 'RF05A-NEWKO' ls_inv_rec-kunnr.

else.

*End of INSERT -SD0K954486

perform bdc_field using 'RF05A-NEWKO' ls_inv_rec-filkd.

*Begin of INSERT - SD0K954486

ENDIF.

*End of INSERT - SD0K954486

perform bdc_field using 'RF05A-NEWBK' ls_inv_rec-bukrs.

perform bdc_field using 'BDC_OKCODE' '/00'.

perform bdc_dynpro using 'SAPMF05A' '0301'.

perform bdc_field using 'BDC_CURSOR' 'RF05A-NEWKO'.

perform bdc_field using 'BSEG-WRBTR' l_wrbtrc.

if ( ls_pay_rec-waers = c_cad and ( ls_inv_rec-bukrs = "dc

c_3000 or ls_inv_rec-bukrs = c_4000 ) ) OR "dc

( ls_pay_rec-waers = c_usd and ls_inv_rec-bukrs = c_1000 ). "dc

l_dmbtrc = l_payment_amt. "dc

perform bdc_field using 'BSEG-DMBTR' l_dmbtrc. "dc

endif. "dc

perform bdc_field using 'BSEG-PYCUR' l_payment_waers.

l_payment_amtc = l_payment_amt.

perform bdc_field using 'BSEG-PYAMT' l_payment_amtc.

perform bdc_field using 'BSEG-KIDNO' ls_pay_rec-zuonr. "dc

perform bdc_field using 'BSEG-ZUONR' ls_inv_rec-zuonr.

perform bdc_field using 'BSEG-SGTXT' ls_match-res_inv_amt_txt.

perform bdc_field using 'BDC_OKCODE' '=ZK'.

perform bdc_dynpro using 'SAPMF05A' '0331'.

perform bdc_field using 'BSEG-XREF1' ls_inv_rec-xref1.

perform bdc_field using 'BSEG-XREF2' ls_inv_rec-xref2.

perform bdc_field using 'BSEG-XREF3' ls_inv_rec-xref3.

perform bdc_field using 'BDC_OKCODE' '=BU'.

* We have to handle to the single case where we may have created

* a document without inserting a record to the restart table.

* If the insert_restart_record_only was set above we don't want to

* create another document, but we did want to go through the process

* to get the correct dunning waers, out_cad etc to allow for the

* correct insertion of the restart record.

if l_insert_restart_record_only = abap_false.

*

* Push everything to memory

*

clear l_arch.

l_arch-zzfwset = ls_inv_rec-xref1_hd(13).

l_arch-zzversn = ls_inv_rec-xref1_hd+13(3).

l_arch-zzvessel = ls_inv_rec-zzcpr01.

l_arch-zzvoyage = ls_inv_rec-zzcpr02.

l_arch-zzbol = ls_inv_rec-zzcpr03.

l_arch-zzcustref = ls_inv_rec-zzcpr04.

l_kursf = l_kursfc.

call function 'Z_U0030_EXP_IMP_KURSF'

EXPORTING

x_export_flag = 'X'

x_kursf = l_kursf.

call function 'Z_U0041_EXP_IMP_VBRK'

EXPORTING

x_export_flag = 'X'

x_zvbakarch = l_arch.

CALL TRANSACTION 'FB01' USING BDCDATA

MODE CTUMODE

UPDATE CUPDATE

MESSAGES INTO lt_messtab.

else.

* Set the flag back and insert a dummy successful record into

* the message tab to force the restart records creation

l_insert_restart_record_only = abap_false.

lt_messtab-msgtyp = 'S'.

append lt_messtab.

endif.

loop at lt_messtab where msgtyp = 'E'

or msgtyp = 'S'.

CALL FUNCTION 'RH_MESSAGE_GET'

EXPORTING

ARBGB = lt_messtab-msgid

MSGNR = lt_messtab-msgnr

MSGV1 = lt_messtab-msgv1

MSGV2 = lt_messtab-msgv2

MSGV3 = lt_messtab-msgv3

MSGV4 = lt_messtab-msgv3

IMPORTING

MSGTEXT = gt_alv_data-proftxt

EXCEPTIONS

MESSAGE_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.

if lt_messtab-msgtyp = 'E'.

l_msgnr = lt_messtab-msgnr.

perform write_applog using ls_pay_rec-zuonr

'E' lt_messtab-msgid

l_msgnr

lt_messtab-msgv1

lt_messtab-msgv2

lt_messtab-msgv3

lt_messtab-msgv4.

g_email = abap_true.

gt_alv_data-wrbtr = l_wrbtr.

gt_alv_data-dmbtr = l_payment_amt.

append gt_alv_data.

ls_inv_rec-error = abap_true.

modify gt_oi_extr from ls_inv_rec

transporting error

where zuonr = ls_inv_rec-zuonr.

else.

modify gt_oi_extr from ls_inv_rec

transporting dunning_waers

outs_cad "dc

outs_usd "dc

where zuonr = ls_inv_rec-zuonr.

clear gs_processed.

move-corresponding ls_match to gs_processed.

move p_fnum to gs_processed-file_count.

gs_processed-dunning_waers = ls_inv_rec-dunning_waers.

gs_processed-outs_cad = ls_inv_rec-outs_cad.

gs_processed-outs_usd = ls_inv_rec-outs_usd.

if not ls_pay_rec-transfer_kunnr is initial.

gs_processed-transfer_kunnr = ls_pay_rec-transfer_kunnr.

endif.

gs_processed-rec_count = g_record_count.

gs_processed-flag = abap_true.

CALL FUNCTION 'ZFI_INSERT_PA_SAP_INPUT'

EXPORTING

I_PROCESSED = gs_processed

IMPORTING

E_SUBRC = l_subrc.

if l_subrc = 0.

commit work.

endif.

exit.

endif.

endloop.

refresh lt_messtab.

endloop.

ENDFORM. " process_pa_input

*&---------------------------------------------------------------------*

*& Form bdc_dynpro

*&---------------------------------------------------------------------*

FORM BDC_DYNPRO USING PROGRAM DYNPRO.

CLEAR BDCDATA.

BDCDATA-PROGRAM = PROGRAM.

BDCDATA-DYNPRO = DYNPRO.

BDCDATA-DYNBEGIN = 'X'.

APPEND BDCDATA.

ENDFORM. " bdc_dynpro

*&---------------------------------------------------------------------*

*& Form bdc_field

*&---------------------------------------------------------------------*

* text

*----------------------------------------------------------------------*

* -->P_0598 text

* -->P_0599 text

*----------------------------------------------------------------------*

FORM BDC_FIELD USING FNAM FVAL.

CLEAR BDCDATA.

BDCDATA-FNAM = FNAM.

BDCDATA-FVAL = FVAL.

APPEND BDCDATA.

ENDFORM. " bdc_field

*&---------------------------------------------------------------------*

*& Form move_from_dummy

*&---------------------------------------------------------------------*

* text

*----------------------------------------------------------------------*

* -->P_LS_MATCH text

* -->P_LS_INV_REC text

* -->P_LS_PAY_REC text

*----------------------------------------------------------------------*

FORM move_from_dummy using LS_MATCH structure gs_match

LS_INV_REC structure gs_oi_extr

LS_PAY_REC structure gs_oi_extr

changing f_subrc.

data: lt_messtab like bdcmsgcoll occurs 0 with header line,

l_blart type blart,

l_kursfc(10) type c,

l_kursf type kursf,

l_payment_waers type waers,

l_waers type waers,

l_dmbtr type dmbtr,

l_wrbtr type wrbtr,

l_dmbtrc(13) type c,

l_wrbtrc(13) type c,

l_amt type dmbtr,

l_arch type zvbakarch,

l_payment_amtc(13) type c,

lt_match type table of t_match,

l_payment_amt like bseg-pyamt,

l_msgnr(3) type n,

l_subrc like sy-subrc,

l_open type c.

data: ctumode like ctu_params-dismode,

cupdate like ctu_params-updmode value 'S'.

ctumode = p_mode.

clear: bdcdata, l_blart, l_kursfc, l_dmbtr,

l_payment_waers, l_wrbtr, gt_alv_data.

refresh: bdcdata.

gt_alv_data-payment = ls_match-pymt_belnr.

gt_alv_data-invoice = ls_match-inv_belnr.

gt_alv_data-p_bukrs = ls_match-bukrs.

gt_alv_data-i_bukrs = ls_match-inv_co_cd.

gt_alv_data-p_kunnr = ls_match-pymt_ho_kunnr.

gt_alv_data-i_kunnr = ls_pay_rec-kunnr.

gt_alv_data-userid = ls_match-pa_user_id.

l_blart = ls_pay_rec-blart.

* DC Changed the $ logic below 2005/05/08

* Figure out currencies and amounts

if ls_pay_rec-waers = c_cad.

l_payment_waers = c_usd.

l_kursfc = ls_pay_rec-xrate_cad2usd.

l_amt = ls_pay_rec-orig_cad * -1.

l_wrbtr = l_amt.

l_payment_amt = ls_pay_rec-orig_usd * -1.

if ls_pay_rec-bukrs = c_3000 or ls_pay_rec-bukrs = c_4000.

l_dmbtr = l_payment_amt.

endif.

else.

l_payment_waers = c_cad.

l_kursfc = ls_pay_rec-xrate_usd2cad. "dc

l_amt = ls_pay_rec-orig_usd * -1.

l_wrbtr = l_amt.

l_payment_amt = ls_pay_rec-orig_cad * -1.

if ls_pay_rec-bukrs = c_1000.

l_dmbtr = l_payment_amt.

endif.

endif.

* Make sure payment amount isn't too long for the screen.

l_payment_amtc = l_payment_amt.

l_wrbtrc = l_wrbtr.

if not l_dmbtr is initial.

l_dmbtrc = l_dmbtr.

endif.

perform bdc_dynpro using 'SAPMF05A' '0100'.

perform bdc_field using: 'BDC_CURSOR' 'RF05A-NEWKO',

'BKPF-BLDAT' ls_pay_rec-bldat.

perform bdc_field using 'BKPF-BLART' l_blart.

perform bdc_field using 'BKPF-BUKRS' ls_pay_rec-bukrs.

clear l_open.

perform check_period using ls_pay_rec-bldat changing l_open.

if l_open is initial.

perform bdc_field using 'BKPF-BUDAT' ls_pay_rec-bldat.

else.

perform bdc_field using 'BKPF-BUDAT' p_date.

endif.

perform bdc_field using 'BKPF-WAERS' ls_pay_rec-waers.

perform bdc_field using 'BKPF-XBLNR' ls_pay_rec-xblnr.

perform bdc_field using 'BKPF-BKTXT' ls_pay_rec-bktxt.

perform bdc_field using 'RF05A-NEWBS' c_05.

perform bdc_field using 'RF05A-NEWKO' ls_pay_rec-kunnr.

perform bdc_field using 'BDC_OKCODE' '/00'.

perform bdc_dynpro using 'SAPMF05A' '0301'.

perform bdc_field using 'BDC_CURSOR' 'RF05A-NEWKO'.

perform bdc_field using 'BSEG-WRBTR' l_wrbtrc.

if not l_dmbtr is initial.

perform bdc_field using 'BSEG-DMBTR' l_dmbtrc.

endif.

perform bdc_field using 'BSEG-PYCUR' l_payment_waers.

perform bdc_field using 'BSEG-PYAMT' l_payment_amtc.

perform bdc_field using 'BSEG-KIDNO' ls_pay_rec-zuonr.

perform bdc_field using 'BSEG-ZUONR' ls_pay_rec-zuonr.

perform bdc_field using 'BSEG-SGTXT' ls_pay_rec-sgtxt.

perform bdc_field using 'BDC_OKCODE' '=ZK'.

perform bdc_dynpro using 'SAPMF05A' '0331'.

perform bdc_field using 'RF05A-NEWBS' c_15.

perform bdc_field using 'BSEG-XREF1' ls_pay_rec-xref1.

perform bdc_field using 'BSEG-XREF2' ls_pay_rec-xref2.

perform bdc_field using 'BSEG-XREF3' ls_pay_rec-xref3.

perform bdc_field using 'RF05A-NEWKO' ls_match-pymt_ho_kunnr.

perform bdc_field using 'RF05A-NEWBK' ls_pay_rec-bukrs.

perform bdc_field using 'BDC_OKCODE' '/00'.

perform bdc_dynpro using 'SAPMF05A' '0301'.

perform bdc_field using 'BDC_CURSOR' 'RF05A-NEWKO'.

perform bdc_field using 'BSEG-WRBTR' l_wrbtrc.

if not l_dmbtr is initial.

perform bdc_field using 'BSEG-DMBTR' l_dmbtrc.

endif.

perform bdc_field using 'BSEG-PYCUR' l_payment_waers.

perform bdc_field using 'BSEG-PYAMT' l_payment_amtc.

perform bdc_field using 'BSEG-KIDNO' ls_pay_rec-zuonr.

perform bdc_field using 'BSEG-ZUONR' ls_pay_rec-zuonr.

perform bdc_field using 'BSEG-SGTXT' ls_pay_rec-sgtxt.

perform bdc_field using 'BDC_OKCODE' '=ZK'.

perform bdc_dynpro using 'SAPMF05A' '0331'.

perform bdc_field using 'BSEG-XREF1' ls_pay_rec-xref1.

perform bdc_field using 'BSEG-XREF2' ls_pay_rec-xref2.

perform bdc_field using 'BSEG-XREF3' ls_pay_rec-xref3.

perform bdc_field using 'BDC_OKCODE' '=BU'.

*

* Push everything to memory

*

clear l_arch.

l_arch-zzfwset = ls_inv_rec-xref1_hd(13).

l_arch-zzversn = ls_inv_rec-xref1_hd+13(3).

l_arch-zzvessel = ls_inv_rec-zzcpr01.

l_arch-zzvoyage = ls_inv_rec-zzcpr02.

l_arch-zzbol = ls_inv_rec-zzcpr03.

l_arch-zzcustref = ls_inv_rec-zzcpr04.

l_kursf = l_kursfc.

call function 'Z_U0030_EXP_IMP_KURSF'

EXPORTING

x_export_flag = 'X'

x_kursf = l_kursf.

call function 'Z_U0041_EXP_IMP_VBRK'

EXPORTING

x_export_flag = 'X'

x_zvbakarch = l_arch.

CALL TRANSACTION 'FB01' USING BDCDATA

MODE CTUMODE

UPDATE CUPDATE

MESSAGES INTO lt_messtab.

loop at lt_messtab where msgtyp = 'E'

or msgtyp = 'S'.

CALL FUNCTION 'RH_MESSAGE_GET'

EXPORTING

ARBGB = lt_messtab-msgid

MSGNR = lt_messtab-msgnr

MSGV1 = lt_messtab-msgv1

MSGV2 = lt_messtab-msgv2

MSGV3 = lt_messtab-msgv3

MSGV4 = lt_messtab-msgv3

IMPORTING

MSGTEXT = gt_alv_data-proftxt

EXCEPTIONS

MESSAGE_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.

if lt_messtab-msgtyp = 'E'.

l_msgnr = lt_messtab-msgnr.

perform write_applog using ls_pay_rec-zuonr

'E' lt_messtab-msgid

l_msgnr

lt_messtab-msgv1

lt_messtab-msgv2

lt_messtab-msgv3

lt_messtab-msgv4.

g_email = abap_true.

gt_alv_data-wrbtr = l_wrbtr.

gt_alv_data-dmbtr = l_payment_amt.

append gt_alv_data.

f_subrc = 4.

else.

clear gs_processed.

move-corresponding ls_match to gs_processed.

move p_fnum to gs_processed-file_count.

gs_processed-transfer_kunnr = ls_match-pymt_ho_kunnr.

gs_processed-rec_count = g_record_count.

CALL FUNCTION 'ZFI_INSERT_PA_SAP_INPUT'

EXPORTING

I_PROCESSED = gs_processed

IMPORTING

E_SUBRC = l_subrc.

if sy-subrc = 0.

commit work.

endif.

exit.

endif.

endloop.

refresh lt_messtab.

ENDFORM. " move_from_dummy

*&---------------------------------------------------------------------*

*& Form set_dunning_blocks

*&---------------------------------------------------------------------*

* text

*----------------------------------------------------------------------*

* --> p1 text

* <-- p2 text

*----------------------------------------------------------------------*

FORM set_dunning_blocks.

data: l_dun_blk type mansp,

ls_oi_extr like line of gt_oi_extr,

l_return.

loop at gt_oi_extr into ls_oi_extr

where rectype <> c_payment

and error is initial.

clear: gt_alv_data, l_dun_blk.

gt_alv_data-invoice = ls_oi_extr-zuonr.

gt_alv_data-i_bukrs = ls_oi_extr-bukrs.

gt_alv_data-i_kunnr = ls_oi_extr-kunnr.

if ls_oi_extr-dunning_waers = c_cad.

if ls_oi_extr-outs_cad > 0.

l_dun_blk = c_6.

elseif ls_oi_extr-outs_cad < 0.

l_dun_blk = c_4.

endif.

else.

if ls_oi_extr-outs_usd > 0.

l_dun_blk = c_6.

elseif ls_oi_extr-outs_usd < 0.

l_dun_blk = c_4.

endif.

endif.

if ( l_dun_blk = C_6 or l_dun_blk = c_4 ). "dc

CALL FUNCTION 'ZFI_DUN_BLK_INSERT'

EXPORTING

INVOICE = ls_oi_extr-zuonr

SOURCE = c_p

BUKRS = ls_oi_extr-bukrs

DUN_BLK = l_dun_blk

IMPORTING

UPDATE_SUCCESSFUL = l_return.

if l_return <> c_y.

CALL FUNCTION 'ZFI_DUN_BLK_UPDATE'

EXPORTING

INVOICE = ls_oi_extr-zuonr

SOURCE = c_p

BUKRS = ls_oi_extr-bukrs

DUN_BLK = l_dun_blk

IMPORTING

UPDATE_SUCCESSFUL = l_return.

if l_return <> c_y.

perform write_applog using ls_oi_extr-zuonr

'E' 'ZFI_ISS' '000'

text-011

ls_oi_extr-zuonr

ls_oi_extr-bukrs

' '.

gt_alv_data-proftxt = text-011.

gt_alv_data-error = abap_true.

g_email = abap_true.

append gt_alv_data.

endif.

endif.

endif. "dc

endloop.

ENDFORM. " set_dunning_blocks

*&---------------------------------------------------------------------*

*& Form call_alv

*&---------------------------------------------------------------------*

* text

*----------------------------------------------------------------------*

* --> p1 text

* <-- p2 text

*----------------------------------------------------------------------*

FORM call_alv.

data: l_repid like sy-repid,

l_tabname type slis_tabname.

l_repid = sy-repid.

l_tabname = 'GT_ALV_DATA'.

* generate field catalog for header ALV

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

EXPORTING

I_PROGRAM_NAME = l_repid

I_INTERNAL_TABNAME = l_tabname

I_INCLNAME = l_repid

CHANGING

CT_FIELDCAT = gt_fieldcat

EXCEPTIONS

INCONSISTENT_INTERFACE = 1

PROGRAM_ERROR = 2

OTHERS = 3.

loop at gt_fieldcat into gs_fieldcat.

case gs_fieldcat-fieldname.

when 'PROFTXT'.

gs_fieldcat-outputlen = 50.

gs_fieldcat-seltext_s = text-003.

gs_fieldcat-seltext_m = text-003.

gs_fieldcat-seltext_l = text-003.

gs_fieldcat-ddictxt = 'L'.

when 'INVOICE'.

gs_fieldcat-outputlen = 10.

gs_fieldcat-seltext_s = text-004.

gs_fieldcat-seltext_m = text-004.

gs_fieldcat-seltext_l = text-004.

gs_fieldcat-ddictxt = 'L'.

when 'PAYMENT'.

gs_fieldcat-outputlen = 10.

gs_fieldcat-seltext_s = text-005.

gs_fieldcat-seltext_m = text-005.

gs_fieldcat-seltext_l = text-005.

gs_fieldcat-ddictxt = 'L'.

when 'I_BUKRS'.

gs_fieldcat-outputlen = 12.

gs_fieldcat-seltext_s = text-006.

gs_fieldcat-seltext_m = text-006.

gs_fieldcat-seltext_l = text-006.

gs_fieldcat-ddictxt = 'L'.

when 'P_BUKRS'.

gs_fieldcat-outputlen = 12.

gs_fieldcat-seltext_s = text-007.

gs_fieldcat-seltext_m = text-007.

gs_fieldcat-seltext_l = text-007.

gs_fieldcat-ddictxt = 'L'.

when 'P_KUNNR'.

gs_fieldcat-outputlen = 13.

gs_fieldcat-seltext_s = text-009.

gs_fieldcat-seltext_m = text-009.

gs_fieldcat-seltext_l = text-009.

when 'I_KUNNR'.

gs_fieldcat-outputlen = 10.

gs_fieldcat-seltext_s = text-010.

gs_fieldcat-seltext_m = text-010.

gs_fieldcat-seltext_l = text-010.

when 'DMBTR'.

gs_fieldcat-no_out = 'X'.

when 'USERID'.

gs_fieldcat-seltext_s = text-023.

gs_fieldcat-seltext_m = text-023.

gs_fieldcat-seltext_l = text-023.

gs_fieldcat-ddictxt = 'L'.

endcase.

modify gt_fieldcat from gs_fieldcat.

endloop.

* sort gt_alv_data by error p_bukrs payment .

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

i_callback_program = l_repid

i_default = abap_true

i_save = 'A'

is_layout = gs_alv_layout

it_fieldcat = gt_fieldcat

TABLES

t_outtab = gt_alv_data[].

ENDFORM. " call_alv

*&---------------------------------------------------------------------*

*& Form verify_controls

*&---------------------------------------------------------------------*

* text

*----------------------------------------------------------------------*

* --> p1 text

* <-- p2 text

*----------------------------------------------------------------------*

FORM verify_controls changing f_subrc.

data: ls_cntl type t_cntl,

l_total_amount type wrbtr,

l_credits type wrbtr,

l_debits type wrbtr,

l_integer1 type i,

l_integer2 type i.

describe table gt_match lines g_lines.

read table gt_cntl into ls_cntl

index 1.

check not p_usctl is initial.

l_total_amount = ls_cntl-amount3.

l_credits = ls_cntl-amount2.

l_debits = ls_cntl-amount1.

l_integer1 = ls_cntl-cnt.

l_integer2 = g_lines.

if l_debits <> g_debits or

l_credits <> g_credits or

l_total_amount <> g_total_amount or

l_integer1 <> l_integer2.

set parameter id 'MESSAGE_DISPLAY_TYPE' field 'E'.

f_subrc = 4.

message a899(fi) with text-024

g_lines g_total_amount.

endif.

if g_lines = 0.

exit.

endif.

* Check last interface record

l_total_amount = gs_zar_iface_cntl-total.

l_credits = gs_zar_iface_cntl-total_credits.

l_debits = gs_zar_iface_cntl-total_debits.

l_integer1 = gs_zar_iface_cntl-rec_count.

if l_debits = g_debits and

l_credits = g_credits and

l_total_amount = g_total_amount and

l_integer1 = l_integer2.

set parameter id 'MESSAGE_DISPLAY_TYPE' field 'E'.

f_subrc = 4.

message a899(fi) with text-025 text-026

g_lines g_total_amount.

endif.

ENDFORM. " verify_controls

*&---------------------------------------------------------------------*

*& Form write_applog

*&---------------------------------------------------------------------*

* text

*----------------------------------------------------------------------*

* --> p1 text

* <-- p2 text

*----------------------------------------------------------------------*

FORM write_applog using f_zuonr

f_msgty

f_msgid

f_msgno

f_msgv1

f_msgv2

f_msgv3

f_msgv4.

data: ls_return type bapiret2,

ls_messages type bapiret2.

g_applog_key-object = 'ZARCH'.

g_applog_key-subobject = 'ZPAMP'.

g_applog_key-extnumber = f_zuonr.

g_context-tabname = 'ZFI_ISSM'.

g_context-value = f_zuonr.

call function 'Z_STORE_MSG_ON_APPLICATION_LOG'

EXPORTING

x_object = g_applog_key-object

x_subobject = g_applog_key-subobject

x_extnumber = g_applog_key-extnumber

x_msgty = f_msgty

x_msgid = f_msgid

x_msgno = f_msgno

x_msgv1 = f_msgv1

x_msgv2 = f_msgv2

x_msgv3 = f_msgv3

x_msgv4 = f_msgv4

x_context = g_context

EXCEPTIONS

others = 0.

ENDFORM. " write_applog

*&---------------------------------------------------------------------*

*& Form send_email

*&---------------------------------------------------------------------*

* text

*----------------------------------------------------------------------*

* --> p1 text

* <-- p2 text

*----------------------------------------------------------------------*

FORM send_email.

data:

OBJPACK LIKE SOPCKLSTI1 OCCURS 2 WITH HEADER LINE,

OBJHEAD LIKE SOLISTI1 OCCURS 1 WITH HEADER LINE,

OBJBIN LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE,

OBJTXT LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE,

RECLIST LIKE SOMLRECI1 OCCURS 5 WITH HEADER LINE,

DOC_CHNG LIKE SODOCCHGI1,

TAB_LINES LIKE SY-TABIX,

lt_attach TYPE soli OCCURS 0 with header line.

* msg_lines type tline occurs 0 with header line,

* htm_lines type htmlline occurs 0 with header line.

* email subject:

if sy-sysid <> 'SP1'.

concatenate text-020 text-021 sy-sysid into DOC_CHNG-OBJ_DESCR

separated by space.

else.

DOC_CHNG-OBJ_DESCR = text-020.

endif.

DOC_CHNG-OBJ_NAME = 'REB'.

clear: objpack, objhead, objbin, objtxt.

refresh: objpack, objhead, objbin, objtxt, lt_attach.

perform get_email_text tables objtxt using

'ZARCH_EMAIL_TO_PA_SUPPORT'.

DESCRIBE TABLE OBJTXT LINES TAB_LINES.

DOC_CHNG-DOC_SIZE = ( TAB_LINES - 1 ) * 255 + STRLEN( OBJTXT ).

* Creation of the entry

CLEAR OBJPACK-TRANSF_BIN.

OBJPACK-HEAD_START = 1.

OBJPACK-HEAD_NUM = 0.

OBJPACK-BODY_START = 1.

OBJPACK-BODY_NUM = TAB_LINES.

OBJPACK-DOC_TYPE = 'HTM'.

APPEND OBJPACK.

* Creation of the document attachment

CLEAR OBJBIN.

REFRESH: OBJBIN, lT_ATTACH.

* create an attachment to be used for each Requestor

perform create_shortcut tables lt_attach

using p_email.

LOOP AT lT_ATTACH.

MOVE lT_ATTACH TO OBJBIN.

APPEND OBJBIN.

ENDLOOP.

DESCRIBE TABLE OBJBIN LINES TAB_LINES.

OBJHEAD = 'PA to SAP Errors.SAP'. APPEND OBJHEAD.

* Creation of the entry for the compressed attachment

OBJPACK-TRANSF_BIN = 'X'.

OBJPACK-HEAD_START = 1.

OBJPACK-HEAD_NUM = 1.

OBJPACK-BODY_START = 1.

OBJPACK-BODY_NUM = TAB_LINES.

OBJPACK-DOC_TYPE = 'SAP'.

OBJPACK-OBJ_NAME = 'ZD37'.

OBJPACK-OBJ_DESCR = 'SAP Logon to Transaction shortcut'.

OBJPACK-DOC_SIZE = TAB_LINES * 255.

APPEND OBJPACK.

refresh reclist.

clear reclist.

reclist-rec_type = 'U'.

reclist-express = 'X'.

RECLIST-RECEIVER = p_email.

concatenate RECLIST-RECEIVER '@cpr.ca' into RECLIST-RECEIVER.

CLEAR RECLIST-COPY.

APPEND reclist.

* Send document

CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'

EXPORTING

DOCUMENT_DATA = DOC_CHNG

PUT_IN_OUTBOX = 'X'

TABLES

PACKING_LIST = OBJPACK

OBJECT_HEADER = OBJHEAD

CONTENTS_BIN = OBJBIN

CONTENTS_TXT = OBJTXT

RECEIVERS = RECLIST

EXCEPTIONS

TOO_MANY_RECEIVERS = 1

DOCUMENT_NOT_SENT = 2

OPERATION_NO_AUTHORIZATION = 4

DOCUMENT_TYPE_NOT_EXIST = 5

PARAMETER_ERROR = 6

X_ERROR = 7

ENQUEUE_ERROR = 8

OTHERS = 99.

if sy-subrc = 0.

commit work.

else.

rollback work.

endif.

ENDFORM. " send_email

*&---------------------------------------------------------------------*

*& Form get_email_text

*&---------------------------------------------------------------------*

* text

*----------------------------------------------------------------------*

* -->P_OBJTXT text

* -->P_3719 text

*----------------------------------------------------------------------*

form get_email_text tables objtxt structure SOLISTI1

using TDNAME like THEAD-TDNAME.

data: lt_lines like standard table of TLINE with header line,

l_left type i,

l_size type i,

l_lines type i,

l_objtxt like objtxt,

l_worklist(12) type c,

l_approver(81) type c,

l_pernr like pa0002-pernr,

l_nachn like pa0002-nachn,

l_vorna like pa0002-vorna.

* Main Text:

CALL FUNCTION 'READ_TEXT'

EXPORTING

ID = 'ST'

LANGUAGE = 'E'

NAME = TDNAME

OBJECT = 'TEXT'

TABLES

LINES = lt_lines

EXCEPTIONS

ID = 1

LANGUAGE = 2

NAME = 3

NOT_FOUND = 4

OBJECT = 5

REFERENCE_CHECK = 6

WRONG_ACCESS_TO_ARCHIVE = 7

OTHERS = 8.

* convert standard text to a proper format for email,

* making sure that any hyperlinks are not chopped up and

* formating strings go together...

clear: l_left, l_lines.

loop at lt_lines.

l_objtxt = lt_lines-TDLINE.

l_size = strlen( l_objtxt ).

if l_size < l_left and ( lt_lines-TDFORMAT = '= ' or

lt_lines-TDFORMAT = '' ).

read table objtxt index l_lines.

if lt_lines-TDFORMAT = '='.

concatenate objtxt l_objtxt into l_objtxt.

else.

concatenate objtxt l_objtxt into l_objtxt separated by space.

endif.

while l_objtxt cs '<(><<)>'.

replace '<(><<)>' with '<' into l_objtxt.

endwhile.

move l_objtxt to objtxt.

modify objtxt index l_lines.

else.

while l_objtxt cs '<(><<)>'.

replace '<(><<)>' with '<' into l_objtxt.

endwhile.

move l_objtxt to objtxt.

append objtxt.

add 1 to l_lines.

endif.

l_left = 255 - strlen( objtxt ).

endloop.

ENDFORM. " get_email_text

*&---------------------------------------------------------------------*

*& Form create_shortcut

*&---------------------------------------------------------------------*

* text

*----------------------------------------------------------------------*

* -->P_LT_ATTACH text

* -->P_GT_REBATE_HDR_REQUESTOR text

*----------------------------------------------------------------------*

FORM create_shortcut tables IT_attach structure soli

using W_LOGON.

DATA: lt_short TYPE soli OCCURS 0,

l_short TYPE soli,

W_LOGON_PAR(60) TYPE C.

* GET LOGON PARAMETER - the logon parameter is the

* description on the SAP logon pad of the environment

* that should be set up in the shortcut.

SELECT LOW UP TO 1 ROWS

INTO W_LOGON_PAR FROM TVARV

* WHERE NAME = text-001

WHERE NAME = 'Z_HR_LOGON'

AND TYPE = 'P'.

ENDSELECT.

IF SY-SUBRC > 0.

rollback work.

MESSAGE E037(ZH) with text-019.

ENDIF.

APPEND '[System]' TO lt_short.

CONCATENATE 'Name=' sy-sysid INTO l_short.

APPEND l_short TO lt_short.

CONCATENATE 'Client=' sy-mandt INTO l_short.

APPEND l_short TO lt_short.

CONCATENATE 'Description=' W_LOGON_PAR INTO l_short.

APPEND l_short TO lt_short.

APPEND '[User]' TO lt_short.

CONCATENATE 'Name=' W_LOGON into l_short.

APPEND l_short TO lt_short.

CONCATENATE 'Language=' SY-LANGU INTO L_SHORT.

APPEND L_SHORT TO lt_short.

APPEND '[Function]' TO lt_short.

APPEND 'Title=Rejected Rebates'

TO lt_short.

CONCATENATE 'Command=' 'ZD37' INTO l_short.

APPEND l_short TO lt_short.

APPEND 'Type=Transaction' to lt_short.

CALL FUNCTION 'SO_RAW_TO_RTF'

TABLES

objcont_old = lt_short

objcont_new = IT_attach.

ENDFORM. " create_shortcut

*&---------------------------------------------------------------------*

*& Form create_control_file

*&---------------------------------------------------------------------*

* text

*----------------------------------------------------------------------*

* --> p1 text

* <-- p2 text

*----------------------------------------------------------------------*

FORM create_control_file.

clear gs_zar_iface_cntl.

move g_lines to gs_zar_iface_cntl-rec_count.

move c_subobject to gs_zar_iface_cntl-iface_id.

move c_direction to gs_zar_iface_cntl-direction.

move sy-datum to gs_zar_iface_cntl-lastrundt.

move sy-uzeit to gs_zar_iface_cntl-lastruntm.

move sy-uname to gs_zar_iface_cntl-uname.

move g_credits to gs_zar_iface_cntl-total_credits.

move g_debits to gs_zar_iface_cntl-total_debits.

move g_total_amount to gs_zar_iface_cntl-total.

move 0 to gs_zar_iface_cntl-status.

perform get_current_batch_info.

if p_rad1 = 'X'.

move p_pcfile to gs_zar_iface_cntl-filename.

elseif p_rad2 = 'X'.

move p_apfile to gs_zar_iface_cntl-filename.

endif.

insert zar_iface_cntl from gs_zar_iface_cntl.

if sy-subrc <> 0.

write:/ 'Error in Updating Header Record'.

exit.

endif.

ENDFORM. " create_control_file

*&---------------------------------------------------------------------*

*& Form get_current_batch_info

*&---------------------------------------------------------------------*

* text

*----------------------------------------------------------------------*

* --> p1 text

* <-- p2 text

*----------------------------------------------------------------------*

FORM get_current_batch_info.

call function 'NUMBER_GET_NEXT'

EXPORTING

nr_range_nr = c_nrrangenr

object = c_object

subobject = c_subobject

IMPORTING

number = gs_zar_iface_cntl-batch_no

EXCEPTIONS

interval_not_found = 1

number_range_not_intern = 2

object_not_found = 3

quantity_is_0 = 4

quantity_is_not_1 = 5

interval_overflow = 6

buffer_overflow = 7

others = 8.

if sy-subrc <> 0.

message id sy-msgid type sy-msgty number sy-msgno

with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

write:/ 'Error in Getting Next Header Batch Number'.

endif.

ENDFORM. " get_current_batch_info

*&---------------------------------------------------------------------*

*& Form check_period

*&---------------------------------------------------------------------*

* text

*----------------------------------------------------------------------*

* -->P_LS_MATCH_CHQ_REC_YYMMDD text

*----------------------------------------------------------------------*

FORM check_period USING f_yymmdd changing f_open.

data: l_period type frper,

l_gjahr type gjahr.

l_period = f_yymmdd+4(2).

l_gjahr = f_yymmdd(4).

select count( * ) from t001b

where bukrs = c_cpr

and frye1 = l_gjahr

and frpe1 = l_period

and mkoar = 'D'.

if sy-dbcnt = 0.

f_open = abap_true.

else.

clear f_open.

endif.

ENDFORM. " check_period

*&---------------------------------------------------------------------*

*& Form move_file

*&---------------------------------------------------------------------*

* text

*----------------------------------------------------------------------*

* --> p1 text

* <-- p2 text

*----------------------------------------------------------------------*

FORM move_file.

data: lt_unix_protocol type standard table of btcxpm,

l_input_target type char128,

l_unix_parms type btcxpgpar,

l_filename type char128,

l_unix_status type btcxpgstat,

l_unix_command type sxpglogcmd,

l_unix_exitcode type btcxpgexit.

if p_rad2 = abap_true.

l_filename = p_apfile.

concatenate p_move sy-datum into l_input_target.

else.

l_filename = g_file_input.

l_input_target = g_file_processed.

endif.

if sy-opsys+0(1) eq 'W'.

* Windows operating system

concatenate 'move'

l_filename

l_input_target

into l_unix_parms

separated by space.

l_unix_command = 'Z_WIN_COMMAND'.

else.

* Unix operating system (assumed)

concatenate l_filename

l_input_target

into l_unix_parms

separated by space.

l_unix_command = 'Z_ARCH_MV'.

endif.

call function 'SXPG_COMMAND_EXECUTE'

EXPORTING

commandname = l_unix_command

additional_parameters = l_unix_parms

IMPORTING

status = l_unix_status

exitcode = l_unix_exitcode

TABLES

exec_protocol = lt_unix_protocol

EXCEPTIONS

no_permission = 1

command_not_found = 2

parameters_too_long = 3

security_risk = 4

wrong_check_call_interface = 5

program_start_error = 6

program_termination_error = 7

x_error = 8

parameter_expected = 9

too_many_parameters = 10

illegal_command = 11

wrong_asynchronous_parameters = 12

cant_enq_tbtco_entry = 13

jobcount_generation_error = 14

others = 15.

clear: l_input_target, l_filename, l_unix_parms.

if p_rad2 = abap_true.

l_filename = p_apctl.

concatenate p_mvctl sy-datum into l_input_target.

else.

l_filename = g_file_cntl.

l_input_target = g_file_processed_cntl.

endif.

if sy-opsys+0(1) eq 'W'.

* Windows operating system

concatenate 'move'

l_filename

l_input_target

into l_unix_parms

separated by space.

l_unix_command = 'Z_WIN_COMMAND'.

else.

* Unix operating system (assumed)

concatenate l_filename

l_input_target

into l_unix_parms

separated by space.

l_unix_command = 'Z_ARCH_MV'.

endif.

call function 'SXPG_COMMAND_EXECUTE'

EXPORTING

commandname = l_unix_command

additional_parameters = l_unix_parms

IMPORTING

status = l_unix_status

exitcode = l_unix_exitcode

TABLES

exec_protocol = lt_unix_protocol

EXCEPTIONS

no_permission = 1

command_not_found = 2

parameters_too_long = 3

security_risk = 4

wrong_check_call_interface = 5

program_start_error = 6

program_termination_error = 7

x_error = 8

parameter_expected = 9

too_many_parameters = 10

illegal_command = 11

wrong_asynchronous_parameters = 12

cant_enq_tbtco_entry = 13

jobcount_generation_error = 14

others = 15.

ENDFORM. " move_file

*&---------------------------------------------------------------------*

*& Form get_filenames

*&---------------------------------------------------------------------*

* text

*----------------------------------------------------------------------*

* --> p1 text

* <-- p2 text

*----------------------------------------------------------------------*

FORM get_filenames.

* Get the Input file name

call function 'FILE_GET_NAME'

EXPORTING

logical_filename = c_input

parameter_1 = p_fparm1

* parameter_2 = p_fparm2

IMPORTING

file_name = g_file_input

EXCEPTIONS

file_not_found = 1

others = 2.

if sy-subrc <> 0.

message e137(zarch) with p_fparm1.

* Cannot determine physical file name for logical file name &1

endif.

* Get the Control file name

call function 'FILE_GET_NAME'

EXPORTING

logical_filename = c_input

parameter_1 = p_fparm2

* parameter_2 = p_fparm2

IMPORTING

file_name = g_file_cntl

EXCEPTIONS

file_not_found = 1

others = 2.

if sy-subrc <> 0.

message e137(zarch) with p_fparm2.

* Cannot determine physical file name for logical file name &1

endif.

* Get the Processed Input file name

call function 'FILE_GET_NAME'

EXPORTING

logical_filename = c_processed

parameter_1 = p_fparm1

parameter_2 = sy-datum

IMPORTING

file_name = g_file_processed

EXCEPTIONS

file_not_found = 1

others = 2.

if sy-subrc <> 0.

message e137(zarch) with p_fparm1.

* Cannot determine physical file name for logical file name &1

endif.

* Get the Processed Control file name

call function 'FILE_GET_NAME'

EXPORTING

logical_filename = c_processed

parameter_1 = p_fparm2

parameter_2 = sy-datum

IMPORTING

file_name = g_file_processed_cntl

EXCEPTIONS

file_not_found = 1

others = 2.

if sy-subrc <> 0.

message e137(zarch) with p_fparm2.

* Cannot determine physical file name for logical file name &1

endif.

ENDFORM. " get_filenames

  • No labels