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

upload program to post the accounting document

Former Member
0 Likes
3,435

Hi Experts

There is an issue with the upload program, posting of Accounting document through FB01 Tcode.

Based on the posting keys the screens come up dynamically.

So we cannot predict like which screen will be coming up next for a particular input.

We have 13 posting keys, out of which 11 are working fine but for 2 particular keys it is not coming correctly.

The problem (posting keys 70,31) with that is when I enter asset as account and press enter it will give one pop up

Which is also dynamic. so it is not taking up the value.

So we could not catch it up correctly.

please help us to fix the issue.

with regards

serma

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,947

Serma

It is advisable to use BAPIs instead of BDCs for such transactions.

Use BAPI_ACC_DOCUMENT_POST for posting of Accounting Document. You will find the code online if you search with the BAPI name.

Thanks & regards,

Amol Lohade

6 REPLIES 6
Read only

Former Member
0 Likes
1,948

Serma

It is advisable to use BAPIs instead of BDCs for such transactions.

Use BAPI_ACC_DOCUMENT_POST for posting of Accounting Document. You will find the code online if you search with the BAPI name.

Thanks & regards,

Amol Lohade

Read only

Former Member
0 Likes
1,947

Hi,

Use Program RFBIBL00 to upload the Accounting Documents.

This is a standard Program.

If you want Program i wil send u.

Regards,

Bohra.

Read only

0 Likes
1,947

Hi Bohra.

many thanks for your quick response.

if posible plse giv esome more details.

with regards

serma

Read only

0 Likes
1,947

Hi,

U have to pass ur file structure to the program. I am sending u sample program to post fi documents. Pls go thru it. if you need any clarifications feel free to ask. I have used this prog to post fi documents.

copy and paste this program. Hope ur purpose will b solved.

Code listing for: ZFR003_ADDREVENUE

Description: Revenue Interface for add sales and service fee

________________________________________

&----


*& Report ZFR003_ADDREVENUE

*&

&----


*&

*&

&----


REPORT zfr_003_addrevenue MESSAGE-ID fb .

----


  • Module Finance

----


  • Objective: Sample program to upload Gl documents *

  • the details are selected from accounting tables

  • bkpf,bseg and upload by submitting program to RFBIBL00 *

  • Program : Updates tables ( ) Download data ( ) *

  • Output Lists (X) *

  • *

  • Author : Naveen Bohra *

----


  • Amendment History *

----


  • Who Change ID Reason *

  • Data declation

DATA :w_t001 LIKE t001,

w_gjahr LIKE bkpf-gjahr,

w_poper LIKE t009b-poper,

BEGIN OF it_input1 OCCURS 0,

data(1000),

END OF it_input1,

separator(1) TYPE c VALUE ',',

input_line(1000),

count TYPE i,

i_lines TYPE i,

  • >>>>>>>>>>begin of change +nb13.10.2006

  • occurs 0 is needed explicitly

BEGIN OF it_input OCCURS 0,

ind(1), " indicator for feild

bldat(8), " DOC DATE

blart(2), " DOC TYPE

bukrs(4), " COMPANY CODE

budat(8), " POSTING DATE

waers(5), " CURRENCY

kursf(9), " Exchange rate

xblnr(16), " HEADER REF

bktxt(25), " HEADER TXT

newbs(2), " POSTING KEY

newko(17), " ACCOUNT

newum(1), " SPL GL INDICATOR

wrbtr(13), " AMOUNT IN LOCAL CURRENCY

wmwst(13), "Tax amount in document currency

mwsts(13), "Tax Amount in Local Currency

dmbtr(13), " AMOUNT IN FOR CURRENCY

zterm(4), " PAYAMENT TERMS

zfbdt(10), " BASE LINE DATE

wt_wit(2), " WITH TAXCODE

wt_qs(15), " WITH TAXCODE

wt_qb(15), " WITH TAXAMOUNT

mwskz(2), " TAXCODE

  • secco(4), "section code

bupla(4), " BUSINESS PLACE

newbk(4), " LINE ITEM COMAPNY CODE

kostl(10), " COSTCENTER

aufnr(12), " INTERNAL ORDER

prctr(10), " PROFIT CENTER

pernr(8), " PERSONAL NUMBER

zuonr(18), " ASSIGNMENT

xref1(12), " REF1

xref2(12), " REF2

xref3(20), " REF3

sgtxt(50), " LINE TEXT

END OF it_input,

it_tmp_input LIKE it_input OCCURS 0 WITH HEADER LINE,

it_input_s LIKE it_input OCCURS 0 WITH HEADER LINE.

DATA : file TYPE string,

file1 TYPE string.

DATA : w_path_err(100) TYPE c VALUE '\usr\sap\DEV\interfaces\ERROR\',

w_path_comp(100) TYPE c VALUE '\usr\sap\DEV\interfaces\COMPLETE\'.

  • type declaration for validation of errors

TYPES : BEGIN OF ty_input_err,

xblnr(16), " HEADER REF

item_no(4),

err_text(500),

END OF ty_input_err.

DATA : it_input_err TYPE STANDARD TABLE OF ty_input_err,

wa_input_err LIKE LINE OF it_input_err.

  • varabiles used for validations

DATA : w_post TYPE c,

w_xblnr TYPE bkpf-xblnr,

w_wrbtr(10) TYPE c,

w_wrbtr1(10) TYPE c,

w_wrbtr2(10) TYPE c,

w_adrnr TYPE ad_addrnum,

w_kunnr TYPE kunnr,

w_prev_newko TYPE saknr,

w_newko(10) TYPE c,

w_newko1(10) TYPE c.

*>>>>>>>end of change +nb13.10.2006

DATA :

w_path LIKE rlgrap-filename,

w_file LIKE rlgrap-filename,

w_dir LIKE rlgrap-filename,

w_dir1 LIKE epsf-epsdirnam,

w_file1 LIKE epsf-epsfilnam,

w_flag TYPE i.

DATA : BEGIN OF it_file OCCURS 0.

INCLUDE STRUCTURE epsfili.

DATA: END OF it_file.

FIELD-SYMBOLS: <fs>.

DATA: BEGIN OF bdcdata OCCURS 100.

INCLUDE STRUCTURE bdcdata.

DATA: END OF bdcdata.

DATA : BEGIN OF it_data OCCURS 0,

f1(3000),

END OF it_data.

DATA : wa_bgr00 LIKE bgr00,

wa_bbkpf LIKE bbkpf,

wa_bbseg LIKE bbseg,

w_param_1 LIKE filename-fileintern,

w_param_2 LIKE filename-fileintern,

x_file(500),

w_move_file LIKE epsf-epsfilnam,

w_from_dir LIKE epsf-epsdirnam.

*<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<begin of change +nb13.10.2006

  • type declaration for validations

TYPES : BEGIN OF ty_blart,

blart TYPE t003-blart,

END OF ty_blart.

TYPES : BEGIN OF ty_xblnr,

xblnr TYPE bkpf-xblnr,

END OF ty_xblnr.

TYPES : BEGIN OF ty_mwskz,

mwskz TYPE t007a-mwskz,

END OF ty_mwskz.

TYPES : BEGIN OF ty_qsskz,

qsskz TYPE t059q-qsskz,

END OF ty_qsskz.

TYPES : BEGIN OF ty_zterm,

zterm TYPE t052-zterm,

END OF ty_zterm.

TYPES : BEGIN OF ty_bschl,

bschl TYPE tbsl-bschl,

END OF ty_bschl.

TYPES : BEGIN OF ty_umskz,

umskz TYPE t074u-umskz,

END OF ty_umskz.

*TYPES : BEGIN OF ty_umskz,

  • waers type t074u,

  • end of ty_umskz.

TYPES : BEGIN OF ty_prctr,

prctr TYPE cepc-prctr,

END OF ty_prctr.

TYPES : BEGIN OF ty_kostl,

kostl TYPE csks-kostl,

END OF ty_kostl.

TYPES : BEGIN OF ty_branch,

branch TYPE j_1bbranch-branch,

END OF ty_branch.

TYPES : BEGIN OF ty_seccode,

seccode TYPE seccode-seccode,

END OF ty_seccode.

TYPES : BEGIN OF ty_tbsl,

bschl TYPE tbsl-bschl,

shkzg TYPE tbsl-shkzg,

END OF ty_tbsl.

TYPES : BEGIN OF ty_aufnr,

aufnr TYPE aufk-aufnr,

END OF ty_aufnr.

TYPES : BEGIN OF ty_pernr,

pernr TYPE pa0001-pernr,

END OF ty_pernr.

TYPES : BEGIN OF ty_ska1,

saknr TYPE ska1-saknr,

END OF ty_ska1.

  • internal table used for validations

DATA : it_blart TYPE STANDARD TABLE OF ty_blart,

it_mwskz TYPE STANDARD TABLE OF ty_mwskz,

it_umskz TYPE STANDARD TABLE OF ty_umskz,

it_xblnr TYPE STANDARD TABLE OF ty_xblnr,

it_qsskz TYPE STANDARD TABLE OF ty_qsskz,

it_zterm TYPE STANDARD TABLE OF ty_zterm,

it_bschl TYPE STANDARD TABLE OF ty_bschl,

it_prctr TYPE STANDARD TABLE OF ty_prctr,

it_kostl TYPE STANDARD TABLE OF ty_kostl,

it_branch TYPE STANDARD TABLE OF ty_branch,

it_seccode TYPE STANDARD TABLE OF ty_seccode,

it_tbsl TYPE STANDARD TABLE OF ty_tbsl,

it_aufnr TYPE STANDARD TABLE OF ty_aufnr,

it_pernr TYPE STANDARD TABLE OF ty_pernr,

it_ska1 TYPE STANDARD TABLE OF ty_ska1.

  • work area used for validations

DATA : wa_it_tbsl LIKE LINE OF it_tbsl.

*<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<end of change +nb13.10.2006

DATA : w_date TYPE sy-datum,

w_check TYPE c ,

w_check1 TYPE c,

w_item_no TYPE i.

CONSTANTS : c_under TYPE c VALUE '_',

c_ext(4) TYPE c VALUE '.txt',

c_sf(2) TYPE c VALUE 'SF'.

  • Input file

SELECTION-SCREEN BEGIN OF BLOCK inp WITH FRAME TITLE text-001.

PARAMETERS :

pr_serv RADIOBUTTON GROUP abc DEFAULT 'X',

pr_sfile TYPE filename-fileintern OBLIGATORY,

*change

pr_sfil1 TYPE filename-fileintern OBLIGATORY,

*endchange

pr_lok RADIOBUTTON GROUP abc,

pr_lfile TYPE filename-fileextern ,

*change

pr_lfil1 TYPE filename-fileextern .

*endchange

SELECTION-SCREEN END OF BLOCK inp.

  • --- output

SELECTION-SCREEN BEGIN OF BLOCK out WITH FRAME TITLE text-002.

PARAMETERS : pr_group LIKE bgr00-group OBLIGATORY DEFAULT '1000CAPSULE', " batch input structure for sessiondata

pr_xkeep LIKE bgr00-xkeep DEFAULT 'X' NO-DISPLAY,

pr_max(4) TYPE n DEFAULT '8000',

callmode LIKE rfpdo-rfbifunct , " Function for Generating Posting

pr_nodta LIKE bgr00-nodata DEFAULT '/' NO-DISPLAY,

pr_out LIKE rlgrap-filename,

  • DEFAULT 'SUBSCRIPTION.txt',

pr_err LIKE rlgrap-filename.

  • DEFAULT 'SUBSCRIPTION_ERR.txt'.

SELECTION-SCREEN END OF BLOCK out.

  • Company code and currency

SELECTION-SCREEN BEGIN OF BLOCK def WITH FRAME TITLE text-003.

PARAMETERS : pr_bukrs LIKE t001-bukrs,

pr_waers LIKE bkpf-waers.

SELECTION-SCREEN END OF BLOCK def.

  • Read file.

*Rading the addsales file

PERFORM f001_upload_file_s.

*Reading the addsales service fee.

PERFORM f004_upload_file_sf.

*Validating the addsales file.

PERFORM f002_validate_s.

*

**Validating the addsales service fee.

PERFORM f005_validate_sf.

*If the error table is empty then only do the posting otherwise flash a error.

*IF w_check EQ 'X' AND w_check1 EQ 'X'.

IF w_check EQ 'X'.

*Posting the addsales file

PERFORM f003_create_doc_s.

*Posting the addsales file

PERFORM f006_create_doc_sf. "TABLES it_input_s.

ELSE.

WRITE 😕 text-022.

ENDIF.

&----


*& Form f003_create_doc_s

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM f003_create_doc_s .

LOOP AT it_input.

IF it_data[] IS INITIAL.

PERFORM bdc_bgr00.

ENDIF.

IF NOT it_input-ind IS INITIAL.

PERFORM header_record.

PERFORM item_record.

ELSE.

PERFORM item_record.

ENDIF.

ENDLOOP.

PERFORM save_on_server.

PERFORM post_document.

  • -------------- save file on appl. server -----------------

  • perform save_on_server.

  • -------------- call RFBIBL00 -----------------------------

  • perform call_rfbibl00.

ENDFORM. " f003_create_doc_s

&----


*& Form header_record

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM header_record.

PERFORM fill_in_nodata_character CHANGING wa_bbkpf.

wa_bbkpf-stype = '1'.

wa_bbkpf-tcode = 'FB01'.

  • Check the file is for the valid company code.

SELECT SINGLE * INTO w_t001 FROM t001

WHERE bukrs EQ pr_bukrs.

IF sy-subrc NE 0.

MESSAGE a899 WITH text-007 pr_bukrs.

ENDIF.

  • Determine period

CALL FUNCTION 'FI_PERIOD_DETERMINE'

EXPORTING

i_budat = sy-datum

i_bukrs = pr_bukrs

IMPORTING

e_gjahr = w_gjahr

e_poper = w_poper

EXCEPTIONS

fiscal_year = 1

period = 2

period_version = 3

posting_period = 4

special_period = 5

version = 6

posting_date = 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.

ENDIF.

wa_bbkpf-bukrs = pr_bukrs.

  • begin of change +nb13.10.2006

  • Document type

IF NOT it_input-blart IS INITIAL.

wa_bbkpf-blart = it_input-blart.

ENDIF.

  • Document date and Posting date.

IF NOT it_input-budat IS INITIAL.

wa_bbkpf-budat = it_input-budat.

ENDIF.

IF NOT it_input-bldat IS INITIAL.

wa_bbkpf-bldat = it_input-bldat.

ENDIF.

  • Reference document number

IF NOT it_input-xblnr IS INITIAL.

wa_bbkpf-xblnr = it_input-xblnr.

ENDIF.

  • Currency

wa_bbkpf-waers = pr_waers.

  • wa_bbkpf-kursf = it_input-kursf.

IF NOT it_input-bktxt IS INITIAL.

wa_bbkpf-bktxt = it_input-bktxt.

ENDIF.

APPEND wa_bbkpf TO it_data.

ENDFORM. " header_record

&----


*& Form item_record

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM item_record.

  • Fill BBSEG with no data character .

PERFORM fill_in_nodata_character CHANGING wa_bbseg.

wa_bbseg-stype = '2'.

wa_bbseg-tbnam = 'BBSEG'.

IF NOT it_input-newbs IS INITIAL.

wa_bbseg-newbs = it_input-newbs.

ENDIF.

IF NOT it_input-newko IS INITIAL.

wa_bbseg-newko = it_input-newko.

ENDIF.

IF NOT it_input-newum IS INITIAL.

wa_bbseg-newum = it_input-newum.

ENDIF.

IF NOT it_input-wrbtr IS INITIAL.

wa_bbseg-wrbtr = it_input-wrbtr.

ENDIF.

IF NOT it_input-wmwst IS INITIAL.

wa_bbseg-wmwst = it_input-wmwst.

ENDIF.

IF NOT it_input-mwsts IS INITIAL.

wa_bbseg-mwsts = it_input-mwsts.

ENDIF.

IF NOT it_input-dmbtr IS INITIAL.

wa_bbseg-dmbtr = it_input-dmbtr.

ENDIF.

IF NOT it_input-zterm IS INITIAL.

wa_bbseg-zterm = it_input-zterm.

ENDIF.

IF NOT it_input-zfbdt IS INITIAL.

wa_bbseg-zfbdt = it_input-zfbdt.

ENDIF.

IF NOT it_input-wt_wit IS INITIAL.

wa_bbseg-qsskz = it_input-wt_wit.

ENDIF.

IF NOT it_input-wt_qs IS INITIAL.

wa_bbseg-qsshb = it_input-wt_qs.

ENDIF.

IF NOT it_input-wt_qb IS INITIAL.

wa_bbseg-qsfbt = it_input-wt_qb.

ENDIF.

IF NOT it_input-mwskz IS INITIAL.

wa_bbseg-mwskz = it_input-mwskz.

ENDIF.

  • IF NOT it_input-secco IS INITIAL.

  • wa_bbseg-secco = it_input-secco.

  • ENDIF.

IF it_input-ind IS INITIAL AND NOT it_input-newbk IS INITIAL.

wa_bbseg-newbk = it_input-newbk.

ENDIF.

IF NOT it_input-kostl IS INITIAL.

wa_bbseg-kostl = it_input-kostl.

ENDIF.

IF NOT it_input-aufnr IS INITIAL.

wa_bbseg-aufnr = it_input-aufnr.

ENDIF.

IF NOT it_input-prctr IS INITIAL.

wa_bbseg-prctr = it_input-prctr.

ENDIF.

IF NOT it_input-pernr IS INITIAL.

wa_bbseg-pernr = it_input-pernr.

ENDIF.

IF NOT it_input-zuonr IS INITIAL.

wa_bbseg-zuonr = it_input-zuonr.

ENDIF.

IF NOT it_input-xref1 IS INITIAL.

wa_bbseg-xref1 = it_input-xref1.

ENDIF.

IF NOT it_input-xref2 IS INITIAL.

wa_bbseg-xref2 = it_input-xref2.

ENDIF.

IF NOT it_input-xref3 IS INITIAL.

wa_bbseg-xref3 = it_input-xref3.

ENDIF.

IF NOT it_input-wrbtr IS INITIAL.

wa_bbseg-sgtxt = it_input-sgtxt.

ENDIF.

APPEND wa_bbseg TO it_data.

  • <<<<<<<<<<<<<<<<<<<<<<< end of change +nb>>>>>>>>>>>>>>>>>>>>

ENDFORM. " item_record

&----


*& Form post_document

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM post_document.

PERFORM call_rfbibl00.

ENDFORM. " post_document

&----


*& Form f001_upload_file_s

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM f001_upload_file_s.

IF pr_serv = 'X'.

CONCATENATE sy-datum '_' '*' INTO w_param_1.

  • expenses input data file from application server

  • w_param_1 = 'SUBS*' .

PERFORM get_file_name USING pr_sfile w_param_1

CHANGING x_file.

    • TO Move file from sever for backup storing the file name and path

w_path = x_file.

CALL FUNCTION 'TRINT_SPLIT_FILE_AND_PATH'

EXPORTING

full_name = x_file

IMPORTING

stripped_name = w_move_file

file_path = w_from_dir

EXCEPTIONS

x_error = 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.

PERFORM read_file TABLES it_input

USING x_file.

ELSE.

DATA : w_string TYPE string.

w_string = pr_lfile.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

filename = w_string

filetype = 'ASC'

  • HAS_FIELD_SEPARATOR = 'X'

TABLES

data_tab = it_input1

EXCEPTIONS

file_open_error = 1

file_read_error = 2

no_batch = 3

gui_refuse_filetransfer = 4

invalid_type = 5

no_authority = 6

unknown_error = 7

bad_data_format = 8

header_not_allowed = 9

separator_not_allowed = 10

header_too_long = 11

unknown_dp_error = 12

access_denied = 13

dp_out_of_memory = 14

disk_full = 15

dp_timeout = 16

OTHERS = 17

.

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 it_input1 INTO input_line.

CLEAR: it_input, count.

DO.

ADD 1 TO count.

ASSIGN COMPONENT count OF STRUCTURE it_input TO <fs>.

IF sy-subrc = 0.

SPLIT input_line AT separator INTO <fs> input_line.

ELSE.

EXIT.

ENDIF.

ENDDO.

APPEND it_input.

ENDLOOP.

ENDIF.

ENDFORM. " f001_upload_file_s

&----


*& Form bdc_header

&----


  • text

&----


*& Form bdc_dynpro

&----


  • text

----


  • -->P_0956 text

  • -->P_0957 text

----


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_0961 text

  • -->P_0962 text

----


FORM bdc_field USING fnam fval.

CLEAR bdcdata.

bdcdata-fnam = fnam.

bdcdata-fval = fval.

IF bdcdata-fval NE space.

APPEND bdcdata.

ENDIF.

ENDFORM. " bdc_field

&----


*& Form bdc_items

&----


  • text

&----


*& Form fill_in_nodata_character

&----


  • text

----


  • <--P_WA_BBKPF text

----


FORM fill_in_nodata_character CHANGING p_struc.

FIELD-SYMBOLS: <nodata_field>.

DATA: num TYPE i.

DO.

ADD 1 TO num.

ASSIGN COMPONENT num OF STRUCTURE p_struc TO <nodata_field>.

IF sy-subrc = 0.

<nodata_field> = pr_nodta.

ELSE.

EXIT.

ENDIF.

ENDDO.

ENDFORM. " fill_in_nodata_character

&----


*& Form bdc_bgr00

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM bdc_bgr00.

PERFORM fill_in_nodata_character CHANGING wa_bgr00.

wa_bgr00-stype = '0'.

wa_bgr00-group = pr_group.

wa_bgr00-mandt = sy-mandt.

wa_bgr00-usnam = sy-uname.

wa_bgr00-start = sy-datum.

wa_bgr00-xkeep = pr_xkeep.

APPEND wa_bgr00 TO it_data.

ENDFORM. " bdc_bgr00

&----


*& Form save_on_server

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM save_on_server.

MOVE sy-datum TO w_date.

CONCATENATE w_path_comp pr_out c_under w_date c_ext INTO pr_out.

OPEN DATASET pr_out FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.

LOOP AT it_data.

TRANSFER it_data TO pr_out.

IF sy-subrc NE 0.

MESSAGE i001(mg) WITH pr_out. " error writing to sequential file

MESSAGE a099(mg). " processing terminated

ENDIF.

ENDLOOP.

CLOSE DATASET pr_out .

FREE it_data.

ENDFORM. " save_on_server

&----


*& Form call_rfbibl00

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM call_rfbibl00.

  • Submit file after mapping the data to RFBIBL00

SUBMIT rfbibl00 WITH ds_name = pr_out

WITH callmode = callmode

WITH xlog = 'X'

WITH max_comm = pr_max

WITH pa_xprot = 'X'

AND RETURN.

ENDFORM. " call_rfbibl00

&----


*& Form get_file_name

&----


  • text

----


  • -->P_P_SFILE text

  • -->P_W_PARAM_1 text

----


FORM get_file_name USING p_sfile

w_param_1

CHANGING x_file.

CALL FUNCTION 'FILE_GET_NAME'

EXPORTING

client = sy-mandt

logical_filename = p_sfile

parameter_1 = w_param_1

IMPORTING

file_name = x_file

EXCEPTIONS

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

w_path = x_file.

CALL FUNCTION 'TRINT_SPLIT_FILE_AND_PATH'

EXPORTING

full_name = w_path

IMPORTING

stripped_name = w_file

file_path = w_dir

EXCEPTIONS

x_error = 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.

w_dir1 = w_dir.

w_file1 = w_file.

CALL FUNCTION 'EPS_GET_DIRECTORY_LISTING'

EXPORTING

dir_name = w_dir1

file_mask = w_file1

TABLES

dir_list = it_file

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.

WRITE : / text-006.

ENDIF.

LOOP AT it_file WHERE name CP w_file1.

IF w_flag IS INITIAL.

CONCATENATE w_dir it_file-name INTO x_file.

CONDENSE x_file.

w_flag = 1.

ELSE.

EXIT.

ENDIF.

ENDLOOP.

ENDFORM. " get_file_name

&----


*& Form read_file

&----


  • text

----


  • -->P_X_FILE text

----


FORM read_file TABLES it_tab

USING x_file.

OPEN DATASET x_file FOR INPUT IN TEXT MODE ENCODING DEFAULT.

IF sy-subrc NE 0.

WRITE : / text-006.

ELSE.

DO.

READ DATASET x_file INTO input_line.

IF sy-subrc = 0.

CLEAR: it_input, count.

DO.

ADD 1 TO count.

ASSIGN COMPONENT count OF STRUCTURE it_tab TO <fs>.

IF sy-subrc = 0.

SPLIT input_line AT separator INTO <fs> input_line.

ELSE.

EXIT.

ENDIF.

ENDDO.

APPEND it_tab.

ELSE.

EXIT.

ENDIF.

ENDDO.

ENDIF.

CLOSE DATASET x_file.

ENDFORM. " read_file

&----


*& Form f002_validate_s

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM f002_validate_s .

SELECT blart

FROM t003

INTO TABLE it_blart.

IF sy-subrc NE 0.

CLEAR it_blart.

ENDIF.

SELECT saknr

FROM ska1

INTO TABLE it_ska1.

IF sy-subrc NE 0.

CLEAR it_ska1.

ENDIF.

SELECT mwskz

FROM t007a

INTO TABLE it_mwskz.

IF sy-subrc NE 0.

CLEAR it_mwskz.

ENDIF.

SELECT qsskz

FROM t059q

INTO TABLE it_qsskz.

IF sy-subrc NE 0.

CLEAR it_qsskz.

ENDIF.

SELECT zterm

FROM t052

INTO TABLE it_zterm.

IF sy-subrc NE 0.

CLEAR it_zterm.

ENDIF.

SELECT bschl

FROM tbsl

INTO TABLE it_bschl.

IF sy-subrc NE 0.

CLEAR it_bschl.

ENDIF.

SELECT umskz

FROM t074u

INTO TABLE it_umskz.

IF sy-subrc NE 0.

CLEAR it_umskz.

ENDIF.

SELECT xblnr

FROM bkpf

INTO TABLE it_xblnr.

IF sy-subrc NE 0.

CLEAR it_xblnr.

ENDIF.

SELECT prctr

FROM cepc

INTO TABLE it_prctr.

IF sy-subrc NE 0.

CLEAR it_prctr.

ENDIF.

SELECT kostl

FROM csks

INTO TABLE it_kostl.

IF sy-subrc NE 0.

CLEAR it_kostl.

ENDIF.

SELECT branch

FROM j_1bbranch

INTO TABLE it_branch.

IF sy-subrc NE 0.

CLEAR it_branch.

ENDIF.

SELECT seccode

FROM seccode

INTO TABLE it_seccode.

IF sy-subrc NE 0.

CLEAR it_seccode.

ENDIF.

SELECT bschl shkzg

FROM tbsl

INTO TABLE it_tbsl.

IF sy-subrc NE 0.

CLEAR it_tbsl.

ENDIF.

SELECT aufnr

FROM aufk

INTO TABLE it_aufnr.

IF sy-subrc NE 0.

CLEAR it_aufnr.

ENDIF.

SELECT pernr

FROM pa0001

INTO TABLE it_pernr.

IF sy-subrc NE 0.

CLEAR it_pernr.

ENDIF.

LOOP AT it_input.

CLEAR : wa_input_err,w_check.

  • AT NEW xblnr.

  • CLEAR w_item_no.

  • ENDAT.

*

  • AT NEW xblnr.

  • CLEAR w_wrbtr.

  • ENDAT.

*

  • w_wrbtr = w_wrbtr + it_input-wrbtr.

*checking the whether record is a header record or not.

IF NOT it_input-ind IS INITIAL.

CLEAR w_item_no.

*keeping the track of item number for error record.

w_item_no = w_item_no + 1.

*Checking the total amount in line item eq 0 or not.

IF w_wrbtr NE 0.

MOVE w_xblnr TO wa_input_err-xblnr.

CONCATENATE wa_input_err-err_text text-019 INTO wa_input_err-err_text SEPARATED BY space.

APPEND wa_input_err TO it_input_err.

CLEAR : wa_input_err.

ENDIF.

CLEAR : w_xblnr,w_wrbtr.

*Checking whether the record already posted or not.

READ TABLE it_xblnr

WITH KEY xblnr = it_input-xblnr

TRANSPORTING NO FIELDS.

*If record is already posted then al the line items related to that header are moved to

*the error directory saying that record already posted.

IF sy-subrc EQ 0.

MOVE it_input-xblnr TO wa_input_err-xblnr.

MOVE it_input-xblnr TO w_xblnr.

MOVE text-020 TO wa_input_err-err_text.

APPEND wa_input_err TO it_input_err.

*Setting the flag for keeping the track of the posted items.

MOVE 'X' TO w_post.

*Skipping the current record as it is already posted so no validation is done for that record.

CONTINUE.

*If the record is not posted then all the vaidation will be done and depending existanse in check table

*corresponding enrty is moved to the error table.

ELSE.

CLEAR w_post.

MOVE it_input-xblnr TO w_xblnr.

IF NOT it_input-blart IS INITIAL.

READ TABLE it_blart

WITH KEY blart = it_input-blart

TRANSPORTING NO FIELDS.

IF sy-subrc NE 0.

MOVE w_xblnr TO wa_input_err-xblnr.

MOVE w_item_no TO wa_input_err-item_no.

MOVE text-021 TO wa_input_err-err_text.

ENDIF.

ENDIF.

IF pr_bukrs NE it_input-bukrs.

MOVE w_xblnr TO wa_input_err-xblnr.

MOVE w_item_no TO wa_input_err-item_no.

CONCATENATE wa_input_err-err_text text-008 INTO wa_input_err-err_text SEPARATED BY space.

ENDIF.

IF pr_waers NE it_input-waers.

MOVE w_xblnr TO wa_input_err-xblnr.

MOVE w_item_no TO wa_input_err-item_no.

CONCATENATE wa_input_err-err_text text-009 INTO wa_input_err-err_text SEPARATED BY space.

ENDIF.

IF NOT it_input-mwskz IS INITIAL.

READ TABLE it_mwskz

WITH KEY mwskz = it_input-mwskz

TRANSPORTING NO FIELDS.

IF sy-subrc NE 0.

MOVE w_xblnr TO wa_input_err-xblnr.

MOVE w_item_no TO wa_input_err-item_no.

CONCATENATE wa_input_err-err_text text-010 INTO wa_input_err-err_text SEPARATED BY space.

ENDIF.

ENDIF.

IF NOT it_input-wt_wit IS INITIAL.

READ TABLE it_qsskz

WITH KEY qsskz = it_input-wt_wit

TRANSPORTING NO FIELDS.

IF sy-subrc NE 0.

MOVE w_xblnr TO wa_input_err-xblnr.

MOVE w_item_no TO wa_input_err-item_no.

CONCATENATE wa_input_err-err_text text-011 INTO wa_input_err-err_text SEPARATED BY space.

ENDIF.

ENDIF.

IF NOT it_input-zterm IS INITIAL.

READ TABLE it_zterm

WITH KEY zterm = it_input-zterm

TRANSPORTING NO FIELDS.

IF sy-subrc NE 0.

MOVE w_xblnr TO wa_input_err-xblnr.

MOVE w_item_no TO wa_input_err-item_no.

CONCATENATE wa_input_err-err_text text-012 INTO wa_input_err-err_text SEPARATED BY space.

ENDIF.

ENDIF.

IF NOT it_input-newbs IS INITIAL.

READ TABLE it_bschl

WITH KEY bschl = it_input-newbs

TRANSPORTING NO FIELDS.

IF sy-subrc NE 0.

MOVE w_xblnr TO wa_input_err-xblnr.

MOVE w_item_no TO wa_input_err-item_no.

CONCATENATE wa_input_err-err_text text-013 INTO wa_input_err-err_text SEPARATED BY space.

ENDIF.

ENDIF.

  • IF NOT it_input-newko IS INITIAL.

*

  • READ TABLE it_ska1

  • WITH KEY saknr = it_input-newko

  • TRANSPORTING NO FIELDS.

*

  • IF sy-subrc NE 0.

*

  • MOVE w_xblnr TO wa_input_err-xblnr.

  • MOVE w_item_no TO wa_input_err-item_no.

  • CONCATENATE wa_input_err-err_text text-023 INTO wa_input_err-err_text.

  • ENDIF.

*

  • ENDIF.

*

*Here in this file when posting key is 01 which will come in header-item that is in 1st line

*For this there is no G/L account number but the code from the samba

*So based on this code in samba select the customer account from SAP and pass this value to G/L account.

IF NOT it_input-newko IS INITIAL.

IF w_prev_newko EQ it_input-newko.

*If the previous samba acc code is same as new one then dont calculate customer acc code

*As we obtained previously in w_kunnr field.

*So just pass the kunnr field to the internal table and do the modification.

it_input-newko = w_kunnr.

MODIFY it_input.

ELSE.

*But if samba code is a new one then then obtained the corresponding SAP customer account.

CLEAR : w_kunnr,w_adrnr.

CLEAR w_prev_newko.

SELECT SINGLE addrnumber

FROM adrct

INTO w_adrnr

WHERE remark EQ it_input-newko.

IF sy-subrc EQ 0.

SELECT SINGLE kunnr

FROM kna1

INTO w_kunnr

WHERE adrnr EQ w_adrnr.

IF sy-subrc NE 0.

CLEAR w_kunnr.

ENDIF.

ENDIF.

it_input-newko = w_kunnr.

MODIFY it_input.

MOVE it_input-newko TO w_prev_newko.

ENDIF.

ENDIF.

IF NOT it_input-newum IS INITIAL.

READ TABLE it_umskz

WITH KEY umskz = it_input-newum

TRANSPORTING NO FIELDS.

IF sy-subrc NE 0.

MOVE w_xblnr TO wa_input_err-xblnr.

MOVE w_item_no TO wa_input_err-item_no.

CONCATENATE wa_input_err-err_text text-014 INTO wa_input_err-err_text SEPARATED BY space.

ENDIF.

ENDIF.

IF NOT it_input-prctr IS INITIAL.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING

input = it_input-prctr

IMPORTING

output = it_input-prctr.

READ TABLE it_prctr

WITH KEY prctr = it_input-prctr

TRANSPORTING NO FIELDS.

IF sy-subrc NE 0.

MOVE w_xblnr TO wa_input_err-xblnr.

MOVE w_item_no TO wa_input_err-item_no.

CONCATENATE wa_input_err-err_text text-018 INTO wa_input_err-err_text SEPARATED BY space.

ENDIF.

ENDIF.

IF NOT it_input-kostl IS INITIAL.

READ TABLE it_kostl

WITH KEY kostl = it_input-kostl

TRANSPORTING NO FIELDS.

IF sy-subrc NE 0.

MOVE w_xblnr TO wa_input_err-xblnr.

MOVE w_item_no TO wa_input_err-item_no.

CONCATENATE wa_input_err-err_text text-015 INTO wa_input_err-err_text SEPARATED BY space.

ENDIF.

ENDIF.

IF NOT it_input-bupla IS INITIAL.

READ TABLE it_branch

WITH KEY branch = it_input-bupla

TRANSPORTING NO FIELDS.

IF sy-subrc NE 0.

MOVE w_xblnr TO wa_input_err-xblnr.

CONCATENATE wa_input_err-err_text 'invalid bupla' INTO wa_input_err-err_text SEPARATED BY space.

ENDIF.

ENDIF.

  • IF NOT it_input-aufnr IS INITIAL.

*

  • READ TABLE it_aufnr

  • WITH KEY aufnr = it_input-aufnr

  • TRANSPORTING NO FIELDS.

*

  • IF sy-subrc NE 0.

  • MOVE w_xblnr TO wa_input_err-xblnr.

  • CONCATENATE wa_input_err-err_text 'invalid aufnr' INTO wa_input_err-err_text SEPARATED BY space.

  • ENDIF.

*

*

  • ENDIF.

IF NOT it_input-pernr IS INITIAL.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING

input = it_input-pernr

IMPORTING

output = it_input-pernr.

READ TABLE it_pernr

WITH KEY pernr = it_input-pernr

TRANSPORTING NO FIELDS.

IF sy-subrc NE 0.

MOVE w_xblnr TO wa_input_err-xblnr.

CONCATENATE wa_input_err-err_text 'invalid pernr' INTO wa_input_err-err_text SEPARATED BY space.

ENDIF.

ENDIF.

  • IF NOT it_input-secco IS INITIAL.

*

  • READ TABLE it_seccode

  • WITH KEY seccode = it_input-secco

  • TRANSPORTING NO FIELDS.

*

  • IF sy-subrc NE 0.

  • MOVE w_xblnr TO wa_input_err-xblnr.

  • CONCATENATE wa_input_err-err_text text-016 INTO wa_input_err-err_text SEPARATED BY space.

  • ENDIF.

*

  • ENDIF.

*

*Checking the debit credit indicator for the line item amount.

*if the indicator is credit then amount is multiplied with -1.

*if the indicator is debit then positive amount is retained.

READ TABLE it_tbsl INTO wa_it_tbsl

WITH KEY bschl = it_input-newbs.

IF sy-subrc EQ 0.

IF wa_it_tbsl-shkzg EQ 'S'.

MOVE it_input-wrbtr TO w_wrbtr.

  • MOVE it_input-dmbtr TO w_wrbtr.

ELSE.

w_wrbtr2 = it_input-wrbtr * -1.

  • w_wrbtr2 = it_input-dmbtr * -1.

MOVE w_wrbtr2 TO w_wrbtr.

ENDIF.

ENDIF.

w_wrbtr = w_wrbtr - it_input-wmwst.

ENDIF.

*Finally after performing all the validations if the error table is not empty

*then only move the work area content to the internal table.

IF NOT wa_input_err IS INITIAL.

APPEND wa_input_err TO it_input_err.

ENDIF.

*If the record is not the header record then check whether post flag is initial or not.

*Means it is a item record and it is not posted in the SAP

*So for such entry do all the validations on the item level.

ELSEIF w_post IS INITIAL.

*keeping the track of item number for error record.

w_item_no = w_item_no + 1.

IF NOT it_input-mwskz IS INITIAL.

READ TABLE it_mwskz

WITH KEY mwskz = it_input-mwskz

TRANSPORTING NO FIELDS.

IF sy-subrc NE 0.

MOVE w_xblnr TO wa_input_err-xblnr.

MOVE w_item_no TO wa_input_err-item_no.

CONCATENATE wa_input_err-err_text text-010 INTO wa_input_err-err_text SEPARATED BY space.

ENDIF.

ENDIF.

IF NOT it_input-wt_wit IS INITIAL.

READ TABLE it_qsskz

WITH KEY qsskz = it_input-wt_wit

TRANSPORTING NO FIELDS.

IF sy-subrc NE 0.

MOVE w_xblnr TO wa_input_err-xblnr.

MOVE w_item_no TO wa_input_err-item_no.

CONCATENATE wa_input_err-err_text text-011 INTO wa_input_err-err_text SEPARATED BY space.

ENDIF.

ENDIF.

IF NOT it_input-zterm IS INITIAL.

READ TABLE it_zterm

WITH KEY zterm = it_input-zterm

TRANSPORTING NO FIELDS.

IF sy-subrc NE 0.

MOVE w_xblnr TO wa_input_err-xblnr.

MOVE w_item_no TO wa_input_err-item_no.

CONCATENATE wa_input_err-err_text text-012 INTO wa_input_err-err_text SEPARATED BY space.

ENDIF.

ENDIF.

IF NOT it_input-newbs IS INITIAL.

READ TABLE it_bschl

WITH KEY bschl = it_input-newbs

TRANSPORTING NO FIELDS.

IF sy-subrc NE 0.

MOVE w_xblnr TO wa_input_err-xblnr.

MOVE w_item_no TO wa_input_err-item_no.

CONCATENATE wa_input_err-err_text text-013 INTO wa_input_err-err_text SEPARATED BY space.

ENDIF.

ENDIF.

IF NOT it_input-newum IS INITIAL.

READ TABLE it_umskz

WITH KEY umskz = it_input-newum

TRANSPORTING NO FIELDS.

IF sy-subrc NE 0.

MOVE w_xblnr TO wa_input_err-xblnr.

MOVE w_item_no TO wa_input_err-item_no.

CONCATENATE wa_input_err-err_text text-014 INTO wa_input_err-err_text SEPARATED BY space.

ENDIF.

ENDIF.

IF NOT it_input-prctr IS INITIAL.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING

input = it_input-prctr

IMPORTING

output = it_input-prctr.

READ TABLE it_prctr

WITH KEY prctr = it_input-prctr

TRANSPORTING NO FIELDS.

IF sy-subrc NE 0.

MOVE w_xblnr TO wa_input_err-xblnr.

MOVE w_item_no TO wa_input_err-item_no.

CONCATENATE wa_input_err-err_text text-018 INTO wa_input_err-err_text SEPARATED BY space.

ENDIF.

ENDIF.

IF NOT it_input-kostl IS INITIAL.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING

input = it_input-kostl

IMPORTING

output = it_input-kostl.

READ TABLE it_kostl

WITH KEY kostl = it_input-kostl

TRANSPORTING NO FIELDS.

IF sy-subrc NE 0.

MOVE w_xblnr TO wa_input_err-xblnr.

MOVE w_item_no TO wa_input_err-item_no.

CONCATENATE wa_input_err-err_text text-015 INTO wa_input_err-err_text SEPARATED BY space.

ENDIF.

ENDIF.

IF NOT it_input-bupla IS INITIAL.

READ TABLE it_branch

WITH KEY branch = it_input-bupla

TRANSPORTING NO FIELDS.

IF sy-subrc NE 0.

MOVE w_xblnr TO wa_input_err-xblnr.

MOVE w_item_no TO wa_input_err-item_no.

CONCATENATE wa_input_err-err_text 'invalid bupla' INTO wa_input_err-err_text SEPARATED BY space.

.

ENDIF.

ENDIF.

IF NOT it_input-newko IS INITIAL.

MOVE it_input-newko TO w_newko.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING

input = w_newko

IMPORTING

output = w_newko.

READ TABLE it_ska1

WITH KEY saknr = w_newko

TRANSPORTING NO FIELDS.

IF sy-subrc NE 0.

MOVE w_xblnr TO wa_input_err-xblnr.

MOVE w_item_no TO wa_input_err-item_no.

CONCATENATE wa_input_err-err_text text-023 INTO wa_input_err-err_text.

ENDIF.

ENDIF.

  • IF NOT it_input-aufnr IS INITIAL.

*

  • READ TABLE it_aufnr

  • WITH KEY aufnr = it_input-aufnr

  • TRANSPORTING NO FIELDS.

*

  • IF sy-subrc NE 0.

  • MOVE w_xblnr TO wa_input_err-xblnr.

  • CONCATENATE wa_input_err-err_text 'invalid aufnr' INTO wa_input_err-err_text SEPARATED BY space.

  • ENDIF.

*

*

  • ENDIF.

IF NOT it_input-pernr IS INITIAL.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING

input = it_input-pernr

IMPORTING

output = it_input-pernr.

READ TABLE it_pernr

WITH KEY pernr = it_input-pernr

TRANSPORTING NO FIELDS.

IF sy-subrc NE 0.

MOVE w_xblnr TO wa_input_err-xblnr.

CONCATENATE wa_input_err-err_text 'invalid pernr' INTO wa_input_err-err_text SEPARATED BY space.

ENDIF.

ENDIF.

  • IF NOT it_input-secco IS INITIAL.

*

  • READ TABLE it_seccode

  • WITH KEY seccode = it_input-secco

  • TRANSPORTING NO FIELDS.

*

  • IF sy-subrc NE 0.

  • MOVE w_xblnr TO wa_input_err-xblnr.

  • MOVE w_item_no TO wa_input_err-item_no.

  • CONCATENATE wa_input_err-err_text text-016 INTO wa_input_err-err_text SEPARATED BY space.

  • ENDIF.

*

  • ENDIF.

*

*Checking the debit credit indicator for the line item amount.

*if the indicator is credit then amount is multiplied with -1.

*if the indicator is debit then positive amount is retained.

READ TABLE it_tbsl INTO wa_it_tbsl

WITH KEY bschl = it_input-newbs.

IF sy-subrc EQ 0.

CLEAR w_wrbtr1.

IF wa_it_tbsl-shkzg EQ 'S'.

MOVE it_input-wrbtr TO w_wrbtr1.

  • MOVE it_input-dmbtr TO w_wrbtr1.

ELSE.

w_wrbtr2 = it_input-wrbtr * -1 .

  • w_wrbtr2 = it_input-dmbtr * -1 .

MOVE w_wrbtr2 TO w_wrbtr1.

ENDIF.

ENDIF.

*Adding the all the item amount.

w_wrbtr = w_wrbtr + w_wrbtr1.

*Finally after performing all the validations if the error table is not empty

*then only move the work area content to the internal table.

IF NOT wa_input_err IS INITIAL.

APPEND wa_input_err TO it_input_err.

ENDIF.

*Finally if the record is not header record and post flag is also set for that

*corresponding header record then skip the current record.

*Means skipping the items which are alredy posted.

ELSE.

CONTINUE.

ENDIF.

  • IF w_post EQ 'X'.

    • IF it_input-ind IS INITIAL.

**

    • MOVE w_xblnr TO wa_input_err-xblnr.

**

    • MOVE 'record already posted' TO wa_input_err-err_text.

**

**

    • ENDIF.

*

  • CONTINUE.

ENDLOOP.

*After all the validation for the all the record in the file if error table filled

*then move the error table to the error file on the server in the ERROR directory.

IF NOT it_input_err IS INITIAL.

WRITE sy-datum TO w_date.

CONCATENATE w_path_err pr_err c_under w_date c_ext INTO file.

OPEN DATASET file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.

LOOP AT it_input_err INTO wa_input_err.

TRANSFER wa_input_err TO file.

IF sy-subrc NE 0.

MESSAGE i001(mg) WITH file. " error writing to sequential file

MESSAGE a099(mg). " processing terminated

ENDIF.

ENDLOOP.

CLOSE DATASET file.

*If error table is empty then flag is set.

ELSE.

MOVE 'X' TO w_check.

ENDIF.

ENDFORM. " f002_validate_s

&----


*& Form f004_upload_file_sf

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM f004_upload_file_sf .

IF pr_serv = 'X'.

CONCATENATE sy-datum '_' '*' INTO w_param_2.

  • expenses input data file from application server

  • w_param_1 = 'SUBS*' .

PERFORM get_file_name_sf USING pr_sfil1 w_param_2

CHANGING x_file.

    • TO Move file from sever for backup storing the file name and path

w_path = x_file.

CALL FUNCTION 'TRINT_SPLIT_FILE_AND_PATH'

EXPORTING

full_name = x_file

IMPORTING

stripped_name = w_move_file

file_path = w_from_dir

EXCEPTIONS

x_error = 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.

PERFORM read_file TABLES it_input_s

USING x_file.

ELSE.

CLEAR : it_input1.

DATA : w_string TYPE string.

w_string = pr_lfil1.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

filename = w_string

filetype = 'ASC'

  • HAS_FIELD_SEPARATOR = 'X'

TABLES

data_tab = it_input1

EXCEPTIONS

file_open_error = 1

file_read_error = 2

no_batch = 3

gui_refuse_filetransfer = 4

invalid_type = 5

no_authority = 6

unknown_error = 7

bad_data_format = 8

header_not_allowed = 9

separator_not_allowed = 10

header_too_long = 11

unknown_dp_error = 12

access_denied = 13

dp_out_of_memory = 14

disk_full = 15

dp_timeout = 16

OTHERS = 17

.

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 it_input1 INTO input_line.

CLEAR: it_input, count.

DO.

ADD 1 TO count.

ASSIGN COMPONENT count OF STRUCTURE it_input_s TO <fs>.

IF sy-subrc = 0.

SPLIT input_line AT separator INTO <fs> input_line.

ELSE.

EXIT.

ENDIF.

ENDDO.

APPEND it_input_s.

ENDLOOP.

ENDIF.

ENDFORM. " f004_upload_file_sf

&----


*& Form f005_validate_sf

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM f005_validate_sf .

CLEAR :it_input_err.

LOOP AT it_input_s.

CLEAR : wa_input_err,w_check1.

  • AT NEW xblnr.

  • CLEAR w_item_no.

  • ENDAT.

*

  • AT NEW xblnr.

  • CLEAR w_wrbtr.

  • ENDAT.

*

  • w_wrbtr = w_wrbtr + it_input_s-wrbtr.

*checking the whether record is a header record or not.

IF NOT it_input_s-ind IS INITIAL.

CLEAR w_item_no.

*keeping the track of item number for error record.

w_item_no = w_item_no + 1.

*Checking the total amount in line item eq 0 or not.

IF w_wrbtr NE 0.

MOVE w_xblnr TO wa_input_err-xblnr.

CONCATENATE wa_input_err-err_text text-019 INTO wa_input_err-err_text SEPARATED BY space.

APPEND wa_input_err TO it_input_err.

CLEAR : wa_input_err.

ENDIF.

CLEAR : w_xblnr,w_wrbtr.

*Checking whether the record already posted or not.

READ TABLE it_xblnr

WITH KEY xblnr = it_input_s-xblnr

TRANSPORTING NO FIELDS.

*If record is already posted then al the line items related to that header are moved to

*the error directory saying that record already posted.

IF sy-subrc EQ 0.

MOVE it_input_s-xblnr TO wa_input_err-xblnr.

MOVE it_input_s-xblnr TO w_xblnr.

MOVE text-020 TO wa_input_err-err_text.

APPEND wa_input_err TO it_input_err.

*Setting the flag for keeping the track of the posted items.

MOVE 'X' TO w_post.

*Skipping the current record as it is already posted so no validation is done for that record.

CONTINUE.

*If the record is not posted then all the vaidation will be done and depending existanse in check table

*corresponding enrty is moved to the error table.

ELSE.

CLEAR w_post.

MOVE it_input_s-xblnr TO w_xblnr.

IF NOT it_input_s-blart IS INITIAL.

READ TABLE it_blart

WITH KEY blart = it_input_s-blart

TRANSPORTING NO FIELDS.

IF sy-subrc NE 0.

MOVE w_xblnr TO wa_input_err-xblnr.

MOVE w_item_no TO wa_input_err-item_no.

MOVE text-021 TO wa_input_err-err_text.

ENDIF.

ENDIF.

IF pr_bukrs NE it_input_s-bukrs.

MOVE w_xblnr TO wa_input_err-xblnr.

MOVE w_item_no TO wa_input_err-item_no.

CONCATENATE wa_input_err-err_text text-008 INTO wa_input_err-err_text SEPARATED BY space.

ENDIF.

IF pr_waers NE it_input_s-waers.

MOVE w_xblnr TO wa_input_err-xblnr.

MOVE w_item_no TO wa_input_err-item_no.

CONCATENATE wa_input_err-err_text text-009 INTO wa_input_err-err_text SEPARATED BY space.

ENDIF.

IF NOT it_input_s-mwskz IS INITIAL.

READ TABLE it_mwskz

WITH KEY mwskz = it_input_s-mwskz

TRANSPORTING NO FIELDS.

IF sy-subrc NE 0.

MOVE w_xblnr TO wa_input_err-xblnr.

MOVE w_item_no TO wa_input_err-item_no.

CONCATENATE wa_input_err-err_text text-010 INTO wa_input_err-err_text SEPARATED BY space.

ENDIF.

ENDIF.

IF NOT it_input_s-wt_wit IS INITIAL.

READ TABLE it_qsskz

WITH KEY qsskz = it_input_s-wt_wit

TRANSPORTING NO FIELDS.

IF sy-subrc NE 0.

MOVE w_xblnr TO wa_input_err-xblnr.

MOVE w_item_no TO wa_input_err-item_no.

CONCATENATE wa_input_err-err_text text-011 INTO wa_input_err-err_text SEPARATED BY space.

ENDIF.

ENDIF.

IF NOT it_input_s-zterm IS INITIAL.

READ TABLE it_zterm

WITH KEY zterm = it_input_s-zterm

TRANSPORTING NO FIELDS.

IF sy-subrc NE 0.

MOVE w_xblnr TO wa_input_err-xblnr.

MOVE w_item_no TO wa_input_err-item_no.

CONCATENATE wa_input_err-err_text text-012 INTO wa_input_err-err_text SEPARATED BY space.

ENDIF.

ENDIF.

IF NOT it_input_s-newbs IS INITIAL.

READ TABLE it_bschl

WITH KEY bschl = it_input_s-newbs

TRANSPORTING NO FIELDS.

IF sy-subrc NE 0.

MOVE w_xblnr TO wa_input_err-xblnr.

MOVE w_item_no TO wa_input_err-item_no.

CONCATENATE wa_input_err-err_text text-013 INTO wa_input_err-err_text SEPARATED BY space.

ENDIF.

ENDIF.

IF NOT it_input_s-newum IS INITIAL.

READ TABLE it_umskz

WITH KEY umskz = it_input_s-newum

TRANSPORTING NO FIELDS.

IF sy-subrc NE 0.

MOVE w_xblnr TO wa_input_err-xblnr.

MOVE w_item_no TO wa_input_err-item_no.

CONCATENATE wa_input_err-err_text text-014 INTO wa_input_err-err_text SEPARATED BY space.

ENDIF.

ENDIF.

IF NOT it_input_s-prctr IS INITIAL.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING

input = it_input_s-prctr

IMPORTING

output = it_input_s-prctr.

READ TABLE it_prctr

WITH KEY prctr = it_input_s-prctr

TRANSPORTING NO FIELDS.

IF sy-subrc NE 0.

MOVE w_xblnr TO wa_input_err-xblnr.

MOVE w_item_no TO wa_input_err-item_no.

CONCATENATE wa_input_err-err_text text-018 INTO wa_input_err-err_text SEPARATED BY space.

ENDIF.

ENDIF.

IF NOT it_input_s-kostl IS INITIAL.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING

input = it_input_s-kostl

IMPORTING

output = it_input_s-kostl.

READ TABLE it_kostl

WITH KEY kostl = it_input_s-kostl

TRANSPORTING NO FIELDS.

IF sy-subrc NE 0.

MOVE w_xblnr TO wa_input_err-xblnr.

MOVE w_item_no TO wa_input_err-item_no.

CONCATENATE wa_input_err-err_text text-015 INTO wa_input_err-err_text SEPARATED BY space.

ENDIF.

ENDIF.

IF NOT it_input_s-bupla IS INITIAL.

READ TABLE it_branch

WITH KEY branch = it_input_s-bupla

TRANSPORTING NO FIELDS.

IF sy-subrc NE 0.

MOVE w_xblnr TO wa_input_err-xblnr.

CONCATENATE wa_input_err-err_text 'invalid bupla' INTO wa_input_err-err_text SEPARATED BY space.

ENDIF.

ENDIF.

*

  • IF NOT it_input_s-newko IS INITIAL.

*

  • READ TABLE it_ska1

  • WITH KEY saknr = it_input_s-newko

  • TRANSPORTING NO FIELDS.

*

  • IF sy-subrc NE 0.

*

  • MOVE w_xblnr TO wa_input_err-xblnr.

  • CONCATENATE wa_input_err-err_text text-023 INTO wa_input_err-err_text.

  • ENDIF.

*

  • ENDIF.

*

  • IF NOT it_input_s-aufnr IS INITIAL.

*

  • READ TABLE it_aufnr

  • WITH KEY aufnr = it_input_s-aufnr

  • TRANSPORTING NO FIELDS.

*

  • IF sy-subrc NE 0.

  • MOVE w_xblnr TO wa_input_err-xblnr.

  • CONCATENATE wa_input_err-err_text 'invalid aufnr' INTO wa_input_err-err_text SEPARATED BY space.

  • ENDIF.

*

*

  • ENDIF.

  • IF NOT it_input_s-pernr IS INITIAL.

*

*

  • CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

  • EXPORTING

  • input = it_input-pernr

  • IMPORTING

  • output = it_input-pernr.

*

*

  • READ TABLE it_pernr

  • WITH KEY pernr = it_input_s-pernr

  • TRANSPORTING NO FIELDS.

*

  • IF sy-subrc NE 0.

  • MOVE w_xblnr TO wa_input_err-xblnr.

  • CONCATENATE wa_input_err-err_text 'invalid pernr' INTO wa_input_err-err_text SEPARATED BY space.

  • ENDIF.

*

*

  • ENDIF.

  • IF NOT it_input_s-secco IS INITIAL.

*

  • READ TABLE it_seccode

  • WITH KEY seccode = it_input_s-secco

  • TRANSPORTING NO FIELDS.

*

  • IF sy-subrc NE 0.

  • MOVE w_xblnr TO wa_input_err-xblnr.

  • CONCATENATE wa_input_err-err_text text-016 INTO wa_input_err-err_text SEPARATED BY space.

  • ENDIF.

*

  • ENDIF.

*Checking the debit credit indicator for the line item amount.

*if the indicator is credit then amount is multiplied with -1.

*if the indicator is debit then positive amount is retained.

READ TABLE it_tbsl INTO wa_it_tbsl

WITH KEY bschl = it_input_s-newbs.

IF sy-subrc EQ 0.

IF wa_it_tbsl-shkzg EQ 'S'.

MOVE it_input_s-wrbtr TO w_wrbtr.

  • MOVE it_input_s-dmbtr TO w_wrbtr.

ELSE.

w_wrbtr2 = it_input_s-wrbtr * -1.

  • w_wrbtr2 = it_input_s-dmbtr * -1.

MOVE w_wrbtr2 TO w_wrbtr.

ENDIF.

ENDIF.

ENDIF.

*Finally after performing all the validations if the error table is not empty

*then only move the work area content to the internal table.

IF NOT wa_input_err IS INITIAL.

APPEND wa_input_err TO it_input_err.

ENDIF.

*If the record is not the header record then check whether post flag is initial or not.

*Means it is a item record and it is not posted in the SAP

*So for such entry do all the validations on the item level.

ELSEIF w_post IS INITIAL.

*keeping the track of item number for error record.

w_item_no = w_item_no + 1.

IF NOT it_input_s-mwskz IS INITIAL.

READ TABLE it_mwskz

WITH KEY mwskz = it_input_s-mwskz

TRANSPORTING NO FIELDS.

IF sy-subrc NE 0.

MOVE w_xblnr TO wa_input_err-xblnr.

MOVE w_item_no TO wa_input_err-item_no.

CONCATENATE wa_input_err-err_text text-010 INTO wa_input_err-err_text SEPARATED BY space.

ENDIF.

ENDIF.

IF NOT it_input_s-wt_wit IS INITIAL.

READ TABLE it_qsskz

WITH KEY qsskz = it_input_s-wt_wit

TRANSPORTING NO FIELDS.

IF sy-subrc NE 0.

MOVE w_xblnr TO wa_input_err-xblnr.

MOVE w_item_no TO wa_input_err-item_no.

CONCATENATE wa_input_err-err_text text-011 INTO wa_input_err-err_text SEPARATED BY space.

ENDIF.

ENDIF.

IF NOT it_input_s-zterm IS INITIAL.

READ TABLE it_zterm

WITH KEY zterm = it_input_s-zterm

TRANSPORTING NO FIELDS.

IF sy-subrc NE 0.

MOVE w_xblnr TO wa_input_err-xblnr.

MOVE w_item_no TO wa_input_err-item_no.

CONCATENATE wa_input_err-err_text text-012 INTO wa_input_err-err_text SEPARATED BY space.

ENDIF.

ENDIF.

IF NOT it_input_s-newbs IS INITIAL.

READ TABLE it_bschl

WITH KEY bschl = it_input_s-newbs

TRANSPORTING NO FIELDS.

IF sy-subrc NE 0.

MOVE w_xblnr TO wa_input_err-xblnr.

MOVE w_item_no TO wa_input_err-item_no.

CONCATENATE wa_input_err-err_text text-013 INTO wa_input_err-err_text SEPARATED BY space.

ENDIF.

ENDIF.

IF NOT it_input_s-newum IS INITIAL.

READ TABLE it_umskz

WITH KEY umskz = it_input_s-newum

TRANSPORTING NO FIELDS.

IF sy-subrc NE 0.

MOVE w_xblnr TO wa_input_err-xblnr.

MOVE w_item_no TO wa_input_err-item_no.

CONCATENATE wa_input_err-err_text text-014 INTO wa_input_err-err_text SEPARATED BY space.

ENDIF.

ENDIF.

IF NOT it_input_s-prctr IS INITIAL.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING

input = it_input_s-prctr

IMPORTING

output = it_input_s-prctr.

READ TABLE it_prctr

WITH KEY prctr = it_input_s-prctr

TRANSPORTING NO FIELDS.

IF sy-subrc NE 0.

MOVE w_xblnr TO wa_input_err-xblnr.

MOVE w_item_no TO wa_input_err-item_no.

CONCATENATE wa_input_err-err_text text-018 INTO wa_input_err-err_text SEPARATED BY space.

ENDIF.

ENDIF.

IF NOT it_input_s-kostl IS INITIAL.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING

input = it_input_s-kostl

IMPORTING

output = it_input_s-kostl.

READ TABLE it_kostl

WITH KEY kostl = it_input_s-kostl

TRANSPORTING NO FIELDS.

IF sy-subrc NE 0.

MOVE w_xblnr TO wa_input_err-xblnr.

MOVE w_item_no TO wa_input_err-item_no.

CONCATENATE wa_input_err-err_text text-015 INTO wa_input_err-err_text SEPARATED BY space.

ENDIF.

ENDIF.

IF NOT it_input_s-bupla IS INITIAL.

READ TABLE it_branch

WITH KEY branch = it_input_s-bupla

TRANSPORTING NO FIELDS.

IF sy-subrc NE 0.

MOVE w_xblnr TO wa_input_err-xblnr.

MOVE w_item_no TO wa_input_err-item_no.

CONCATENATE wa_input_err-err_text 'invalid bupla' INTO wa_input_err-err_text SEPARATED BY space.

.

ENDIF.

ENDIF.

IF NOT it_input_s-newko IS INITIAL.

MOVE it_input_s-newko TO w_newko1.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING

input = w_newko1

IMPORTING

output = w_newko1.

READ TABLE it_ska1

WITH KEY saknr = w_newko1

TRANSPORTING NO FIELDS.

IF sy-subrc NE 0.

MOVE w_xblnr TO wa_input_err-xblnr.

CONCATENATE wa_input_err-err_text text-023 INTO wa_input_err-err_text.

ENDIF.

ENDIF.

  • IF NOT it_input_s-aufnr IS INITIAL.

*

  • READ TABLE it_aufnr

  • WITH KEY aufnr = it_input_s-aufnr

  • TRANSPORTING NO FIELDS.

*

  • IF sy-subrc NE 0.

  • MOVE w_xblnr TO wa_input_err-xblnr.

  • CONCATENATE wa_input_err-err_text 'invalid aufnr' INTO wa_input_err-err_text SEPARATED BY space.

  • ENDIF.

*

*

  • ENDIF.

*

  • IF NOT it_input_s-pernr IS INITIAL.

*

*

  • CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

  • EXPORTING

  • input = it_input-pernr

  • IMPORTING

  • output = it_input-pernr.

*

*

  • READ TABLE it_pernr

  • WITH KEY pernr = it_input_s-pernr

  • TRANSPORTING NO FIELDS.

*

  • IF sy-subrc NE 0.

  • MOVE w_xblnr TO wa_input_err-xblnr.

  • CONCATENATE wa_input_err-err_text 'invalid pernr' INTO wa_input_err-err_text SEPARATED BY space.

  • ENDIF.

*

*

  • ENDIF.

*

*

*

  • IF NOT it_input_s-secco IS INITIAL.

*

  • READ TABLE it_seccode

  • WITH KEY seccode = it_input_s-secco

  • TRANSPORTING NO FIELDS.

*

  • IF sy-subrc NE 0.

  • MOVE w_xblnr TO wa_input_err-xblnr.

  • MOVE w_item_no TO wa_input_err-item_no.

  • CONCATENATE wa_input_err-err_text text-016 INTO wa_input_err-err_text SEPARATED BY space.

  • ENDIF.

*

  • ENDIF.

*Checking the debit credit indicator for the line item amount.

*if the indicator is credit then amount is multiplied with -1.

*if the indicator is debit then positive amount is retained.

READ TABLE it_tbsl INTO wa_it_tbsl

WITH KEY bschl = it_input_s-newbs.

IF sy-subrc EQ 0.

CLEAR w_wrbtr1.

IF wa_it_tbsl-shkzg EQ 'S'.

MOVE it_input_s-wrbtr TO w_wrbtr1.

  • MOVE it_input_s-dmbtr TO w_wrbtr1.

ELSE.

w_wrbtr2 = it_input_s-wrbtr * -1 .

  • w_wrbtr2 = it_input_s-dmbtr * -1 .

MOVE w_wrbtr2 TO w_wrbtr1.

ENDIF.

ENDIF.

*Adding the all the item amount.

w_wrbtr = w_wrbtr + w_wrbtr1.

*Finally after performing all the validations if the error table is not empty

*then only move the work area content to the internal table.

IF NOT wa_input_err IS INITIAL.

APPEND wa_input_err TO it_input_err.

ENDIF.

*Finally if the record is not header record and post flag is also set for that

*corresponding header record then skip the current record.

*Means skipping the items which are alredy posted.

ELSE.

CONTINUE.

ENDIF.

  • IF w_post EQ 'X'.

    • IF it_input-ind IS INITIAL.

**

    • MOVE w_xblnr TO wa_input_err-xblnr.

**

    • MOVE 'record already posted' TO wa_input_err-err_text.

**

**

    • ENDIF.

*

  • CONTINUE.

ENDLOOP.

*After all the validation for the all the record in the file if error table filled

*then move the error table to the error file on the server in the ERROR directory.

IF NOT it_input_err IS INITIAL.

WRITE sy-datum TO w_date.

CONCATENATE w_path_err pr_err c_under c_sf c_under w_date c_ext INTO file.

OPEN DATASET file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.

LOOP AT it_input_err INTO wa_input_err.

TRANSFER wa_input_err TO file.

IF sy-subrc NE 0.

MESSAGE i001(mg) WITH file. " error writing to sequential file

MESSAGE a099(mg). " processing terminated

ENDIF.

ENDLOOP.

CLOSE DATASET file.

*If error table is empty then flag is set.

ELSE.

MOVE 'X' TO w_check1.

ENDIF.

ENDFORM. " f005_validate_sf

&----


*& Form f006_create_doc_sf

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM f006_create_doc_sf .

CLEAR it_data.

REFRESH it_data.

LOOP AT it_input_s.

IF it_data[] IS INITIAL.

PERFORM bdc_bgr00.

ENDIF.

IF NOT it_input_s-ind IS INITIAL.

PERFORM header_record_sf.

PERFORM item_record_sf.

ELSE.

PERFORM item_record_sf.

ENDIF.

ENDLOOP.

PERFORM save_on_server1.

PERFORM post_document.

ENDFORM. " f006_create_doc_sf

&----


*& Form header_record_sf

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM header_record_sf .

PERFORM fill_in_nodata_character CHANGING wa_bbkpf.

wa_bbkpf-stype = '1'.

wa_bbkpf-tcode = 'FB01'.

  • Check the file is for the valid company code.

SELECT SINGLE * INTO w_t001 FROM t001

WHERE bukrs EQ pr_bukrs.

IF sy-subrc NE 0.

MESSAGE a899 WITH text-007 pr_bukrs.

ENDIF.

  • Determine period

CALL FUNCTION 'FI_PERIOD_DETERMINE'

EXPORTING

i_budat = sy-datum

i_bukrs = pr_bukrs

IMPORTING

e_gjahr = w_gjahr

e_poper = w_poper

EXCEPTIONS

fiscal_year = 1

period = 2

period_version = 3

posting_period = 4

special_period = 5

version = 6

posting_date = 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.

ENDIF.

wa_bbkpf-bukrs = pr_bukrs.

  • begin of change +nb13.10.2006

  • Document type

IF NOT it_input_s-blart IS INITIAL.

wa_bbkpf-blart = it_input_s-blart.

ENDIF.

  • Document date and Posting date.

IF NOT it_input_s-budat IS INITIAL.

wa_bbkpf-budat = it_input_s-budat.

ENDIF.

IF NOT it_input_s-bldat IS INITIAL.

wa_bbkpf-bldat = it_input_s-bldat.

ENDIF.

  • Reference document number

IF NOT it_input_s-xblnr IS INITIAL.

wa_bbkpf-xblnr = it_input_s-xblnr.

ENDIF.

  • Currency

wa_bbkpf-waers = pr_waers.

  • wa_bbkpf-kursf = it_input-kursf.

IF NOT it_input_s-bktxt IS INITIAL.

wa_bbkpf-bktxt = it_input_s-bktxt.

ENDIF.

APPEND wa_bbkpf TO it_data.

ENDFORM. " header_record_sf

&----


*& Form item_record_sf

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM item_record_sf .

  • Fill BBSEG with no data character .

PERFORM fill_in_nodata_character CHANGING wa_bbseg.

wa_bbseg-stype = '2'.

wa_bbseg-tbnam = 'BBSEG'.

IF NOT it_input_s-newbs IS INITIAL.

wa_bbseg-newbs = it_input_s-newbs.

ENDIF.

IF NOT it_input_s-newko IS INITIAL.

wa_bbseg-newko = it_input_s-newko.

ENDIF.

IF NOT it_input_s-newum IS INITIAL.

wa_bbseg-newum = it_input_s-newum.

ENDIF.

IF NOT it_input_s-wrbtr IS INITIAL.

wa_bbseg-wrbtr = it_input_s-wrbtr.

ENDIF.

*if not it_input_s-dmbtr is initial.

  • wa_bbseg-dmbtr = it_input_s-dmbtr.

*endif.

IF NOT it_input_s-zterm IS INITIAL.

wa_bbseg-zterm = it_input_s-zterm.

ENDIF.

IF NOT it_input_s-zfbdt IS INITIAL.

wa_bbseg-zfbdt = it_input_s-zfbdt.

ENDIF.

IF NOT it_input_s-wt_wit IS INITIAL.

wa_bbseg-qsskz = it_input_s-wt_wit.

ENDIF.

IF NOT it_input_s-wt_qs IS INITIAL.

wa_bbseg-qsshb = it_input_s-wt_qs.

ENDIF.

IF NOT it_input_s-wt_qb IS INITIAL.

wa_bbseg-qsfbt = it_input_s-wt_qb.

ENDIF.

IF NOT it_input_s-mwskz IS INITIAL.

wa_bbseg-mwskz = it_input_s-mwskz.

ENDIF.

  • IF NOT it_input_s-secco IS INITIAL.

  • wa_bbseg-secco = it_input_s-secco.

  • ENDIF.

IF it_input_s-ind IS INITIAL AND NOT it_input_s-newbk IS INITIAL.

wa_bbseg-newbk = it_input_s-newbk.

ENDIF.

IF NOT it_input_s-kostl IS INITIAL.

wa_bbseg-kostl = it_input_s-kostl.

ENDIF.

IF NOT it_input_s-aufnr IS INITIAL.

wa_bbseg-aufnr = it_input_s-aufnr.

ENDIF.

IF NOT it_input_s-prctr IS INITIAL.

wa_bbseg-prctr = it_input_s-prctr.

ENDIF.

IF NOT it_input_s-pernr IS INITIAL.

wa_bbseg-pernr = it_input_s-pernr.

ENDIF.

IF NOT it_input_s-zuonr IS INITIAL.

wa_bbseg-zuonr = it_input_s-zuonr.

ENDIF.

IF NOT it_input_s-xref1 IS INITIAL.

wa_bbseg-xref1 = it_input_s-xref1.

ENDIF.

IF NOT it_input_s-xref2 IS INITIAL.

wa_bbseg-xref2 = it_input_s-xref2.

ENDIF.

IF NOT it_input_s-xref3 IS INITIAL.

wa_bbseg-xref3 = it_input_s-xref3.

ENDIF.

IF NOT it_input_s-wrbtr IS INITIAL.

wa_bbseg-sgtxt = it_input_s-sgtxt.

ENDIF.

APPEND wa_bbseg TO it_data.

  • <<<<<<<<<<<<<<<<<<<<<<< end of change +nb>>>>>>>>>>>>>>>>>>>>

ENDFORM. " item_record_sf

&----


*& Form save_on_server1

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM save_on_server1 .

MOVE sy-datum TO w_date.

CLEAR pr_out.

CONCATENATE w_path_comp pr_out c_under w_date c_sf c_ext INTO pr_out.

OPEN DATASET pr_out FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.

LOOP AT it_data.

TRANSFER it_data TO pr_out.

IF sy-subrc NE 0.

MESSAGE i001(mg) WITH pr_out. " error writing to sequential file

MESSAGE a099(mg). " processing terminated

ENDIF.

ENDLOOP.

CLOSE DATASET pr_out.

FREE it_data.

ENDFORM. " save_on_server1

&----


*& Form get_file_name_sf

&----


  • text

----


  • -->P_PR_SFIL1 text

  • -->P_W_PARAM_2 text

  • <--P_X_FILE text

----


FORM get_file_name_sf USING p_sfil1

w_param_2

CHANGING x_file.

CLEAR w_flag.

CALL FUNCTION 'FILE_GET_NAME'

EXPORTING

client = sy-mandt

logical_filename = p_sfil1

parameter_1 = w_param_2

IMPORTING

file_name = x_file

EXCEPTIONS

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

w_path = x_file.

CALL FUNCTION 'TRINT_SPLIT_FILE_AND_PATH'

EXPORTING

full_name = w_path

IMPORTING

stripped_name = w_file

file_path = w_dir

EXCEPTIONS

x_error = 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.

w_dir1 = w_dir.

w_file1 = w_file.

CALL FUNCTION 'EPS_GET_DIRECTORY_LISTING'

EXPORTING

dir_name = w_dir1

file_mask = w_file1

TABLES

dir_list = it_file

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.

WRITE : / text-006.

ENDIF.

LOOP AT it_file WHERE name CP w_file1.

IF w_flag IS INITIAL.

CONCATENATE w_dir it_file-name INTO x_file.

CONDENSE x_file.

w_flag = 1.

ELSE.

EXIT.

ENDIF.

ENDLOOP.

ENDFORM. " get_file_name_sf

*Text elements

*----


  • 001 Input file

  • 002 Output

  • 003 Document does not contains items

  • 004 Input file

  • 005 Company code data

  • 006 Session details

  • 007 Company code does not exist

  • 008 Invalid Company Code

  • 009 Invalid Currency

  • 010 Invalid Tax Code

  • 011 Invalid With-holding Tax Code

  • 012 Invalid Payment terms

  • 013 Incorrect Posting key

  • 014 Invalid Spl Gl Indicator

  • 015 Invalid Cost Center

  • 016 Invalid Section Code

  • 017 Invalid Business Place

  • 018 Invalid Profit Center

  • 019 Invalid Amount In Items

  • 020 Record Already Posted

  • 021 Invalid Document Type

  • 022 There are Errors in File. Check Error Directory For List of Errors

  • 023 Invalid GL Account number

*Selection texts

*----


  • CALLMODE Data transfer type

  • PR_BUKRS Company Code

  • PR_ERR Error file

  • PR_GROUP Session name

  • PR_LFIL1 Local service fee file

  • PR_LFILE Local ad revenue file

  • PR_LOK Local

  • PR_MAX No. of docs per commit

  • PR_OUT Output file

  • PR_SERV Server

  • PR_SFIL1 Ad revenue service fee file

  • PR_SFILE Ad revenue invoice file

  • PR_WAERS Currency

*Messages

*----


*

  • Message class: FB

*899 & & & &

*

  • Message class: MG

*001 Error writing to sequential file &

*099 Processing terminated

________________________________________

w. 1998-2005 UK. Sap Release 640

Regards,

Bohra

Read only

0 Likes
1,947

Hi,

But have you actually used this program RFBIBL00 and it worked? What file structure to you pass to it? If possible please show me that file.

thank you...

Read only

0 Likes
1,947

This message was moderated.