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

session method

Former Member
0 Likes
679

hi all,

iam uploading data from flat file using f-02.iam using session method.i got posting keys 40,50,04,14.

40---->debit to ledger account

50---->credit to ledger account

04---->debit to customer account

14---->credit to customer

my flat file is like this

bldat doc type bukrs waers xblnr bktxt bschl saknr wrbtr prctr zuonr sgtxt

08092006 IF 0100 ZAR MCR08092006 Metrocash Router 40 0008501701 0000000010000 0000443805 A01010809061

08092006 IF 0100 ZAR MCR08092006 Metrocash Router 40 0008501701 0000000020000 0000443805 A01010809062

08092006 IF 0100 ZAR MCR08092006 Metrocash Router 40 0008501903 0000000030000 0000443805 SAPO080906

08092006 IF 0100 ZAR MCR08092006 Metrocash Router 50 0008300200 0000000040000 0000444405 123456789012345678

08092006 IF 0100 ZAR MCR08092006 Metrocash Router 14 0210000000 0000000020000 145876B A01010809062

if anybody got code for this just send me.

anser will be rewarded.

regards

praveen

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
623

Hi Praveen

U need not record & all, the standard program does it all for u!!, just write the incoming data in the following format on to the application server & then submit it to the std prog RFBIBL00

BGR00 - - - Session header

BBKPF - - - Header

BBSEG - - - Item

U can just go thru the documentation of the std program RFBIBL00 - - - everything is clearly mentioned there, in case of further doubts feel free to ask

Regards

Sudhir.

5 REPLIES 5
Read only

Former Member
0 Likes
623

Hi Praveen

The standard program <b>RFBIBL00</b> should do the trick for you.

For every transaction run you will have to populate the header record BBKPF & item record BBSEG & write it on to your application server. After all your data from flat-file is written on the application server in the above mentioned format, you will just have to submit it to the standard program

<b>RFBIBL00</b> with the application server path name onto which you have written your flat-file data . . . . . .

The structure format on the application server will appear as follows

BGR00 - - - session header record

BBKPF - - - FB02 Header structure

BBSEG - - - FB02 Item structure

BBSEG - - - FB02 Item structure

- - - - - - - - - - -- - - - -

- - - - - - - - - - - - - - - -

- - - - - - - - - - - - - - - -

BBKPF - - - FB02 Header structure

BBSEG - - - FB02 Item structure

BBSEG - - - FB02 Item structure

- - - - - - - - - - -- - - - -

- - - - - - - - - - - - - - - -

- - - - - - - - - - - - - - - -

BBKPF - - - FB02 Header structure

BBSEG - - - FB02 Item structure

BBSEG - - - FB02 Item structure

- - - - - - - - - - -- - - - -

- - - - - - - - - - - - - - - -

- - - - - - - - - - - - - - - -

Hence submit to the standard program as follows

SUBMIT RFBIBL00 WITH ds_name = "appln server file path"

WITH callmode = 'S'

WITH xlog = 'X'

AND RETURN.

Regards

Sudhir.

Read only

0 Likes
623

hi sudhir,

i uploaded data to internal table it_file.

i got recording like this.

PERFORM bdc_open_group.

LOOP AT it_file.

REFRESH bdcdata.

CLEAR bdcdata.

CONCATENATE : it_file-bldat6(2) '.' it_file-bldat4(2) '.'

it_file-bldat+0(4) INTO lv_bldat.

perform bdc_dynpro using 'SAPMF05A' '0100'.

perform bdc_field using 'BDC_CURSOR'

'RF05A-NEWKO'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'BKPF-BLDAT'

it_file-bldat.

perform bdc_field using 'BKPF-BLART'

it_file-blart.

PACK it_file-bukrs TO lv_ccod.

UNPACK lv_ccod TO lv_ccod.

lv_compco = lv_ccod.

perform bdc_field using 'BKPF-BUKRS'

lv_compco.

perform bdc_field using 'BKPF-BUDAT'

it_file-bldat.

perform bdc_field using 'BKPF-MONAT'

''.

perform bdc_field using 'BKPF-WAERS'

it_file-waers.

perform bdc_field using 'BKPF-XBLNR'

it_file-xblnr.

perform bdc_field using 'BKPF-BKTXT'

it_file-bktxt.

perform bdc_field using 'FS006-DOCID'

'*'.

perform bdc_field using 'RF05A-NEWBS'

it_file-bschl.

perform bdc_field using 'RF05A-NEWKO'

it_file-saknr.

perform bdc_dynpro using 'SAPMF05A' '0300'.

perform bdc_field using 'BDC_CURSOR'

'RF05A-NEWBS'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'BSEG-WRBTR'

it_file-wrbtr.

perform bdc_field using 'BSEG-VALUT'

'08.09.2006'.

perform bdc_field using 'BSEG-ZUONR'

it_file-zuonr.

  • next record must come here

perform bdc_field using 'RF05A-NEWBS'

it_file-bschl.

perform bdc_field using 'RF05A-NEWKO'

it_file-saknr.

perform bdc_field using 'DKACB-FMORE'

'X'.

perform bdc_dynpro using 'SAPLKACB' '0002'.

perform bdc_field using 'BDC_CURSOR'

'COBL-PRCTR'.

perform bdc_field using 'BDC_OKCODE'

'=ENTE'.

perform bdc_field using 'COBL-PRCTR'

it_file-prctr.

perform bdc_dynpro using 'SAPMF05A' '0300'.

perform bdc_field using 'BSEG-WRBTR'

it_file-wrbtr.

perform bdc_field using 'BSEG-ZUONR'

it_file-zuonr.

  • next record must come here

perform bdc_field using 'RF05A-NEWBS'

'40'.

perform bdc_field using 'RF05A-NEWKO'

'8501701'.

perform bdc_dynpro using 'SAPMF05A' '0300'.

perform bdc_field using 'BDC_CURSOR'

'RF05A-NEWKO'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'BSEG-WRBTR'

'200'.

perform bdc_field using 'BSEG-VALUT'

'08.09.2006'.

perform bdc_field using 'BSEG-ZUONR'

'A01010809062'.

  • next record must come here

perform bdc_field using 'RF05A-NEWBS'

'40'.

perform bdc_field using 'RF05A-NEWKO'

'8501903'.

perform bdc_field using 'DKACB-FMORE'

'X'.

perform bdc_dynpro using 'SAPLKACB' '0002'.

perform bdc_field using 'BDC_CURSOR'

'COBL-PRCTR'.

perform bdc_field using 'BDC_OKCODE'

'=ENTE'.

perform bdc_field using 'COBL-PRCTR'

'443805'.

perform bdc_dynpro using 'SAPMF05A' '0300'.

perform bdc_field using 'BDC_CURSOR'

'RF05A-NEWKO'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'BSEG-WRBTR'

'300'.

perform bdc_field using 'BSEG-VALUT'

'08.09.2006'.

perform bdc_field using 'BSEG-ZUONR'

'SAPO080906'.

  • next record must come here

perform bdc_field using 'RF05A-NEWBS'

'50'.

perform bdc_field using 'RF05A-NEWKO'

'8325000'.

perform bdc_field using 'DKACB-FMORE'

'X'.

perform bdc_dynpro using 'SAPLKACB' '0002'.

perform bdc_field using 'BDC_CURSOR'

'COBL-PRCTR'.

perform bdc_field using 'BDC_OKCODE'

'=ENTE'.

perform bdc_field using 'COBL-PRCTR'

'443805'.

perform bdc_dynpro using 'SAPMF05A' '0300'.

perform bdc_field using 'BDC_CURSOR'

'RF05A-NEWKO'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'BSEG-WRBTR'

'400'.

  • next record must come here

perform bdc_field using 'RF05A-NEWBS'

'50'.

perform bdc_field using 'RF05A-NEWKO'

'210000000'.

perform bdc_field using 'DKACB-FMORE'

'X'.

perform bdc_dynpro using 'SAPLKACB' '0002'.

perform bdc_field using 'BDC_CURSOR'

'COBL-PRCTR'.

perform bdc_field using 'BDC_OKCODE'

'=ENTE'.

perform bdc_field using 'COBL-PRCTR'

'444405'.

perform bdc_dynpro using 'SAPMF05A' '0300'.

perform bdc_field using 'BSEG-WRBTR'

'400'.

  • next record must come here

perform bdc_field using 'RF05A-NEWBS'

'14'.

perform bdc_field using 'RF05A-NEWKO'

'121000040'.

perform bdc_dynpro using 'SAPMF05A' '0301'.

perform bdc_field using 'BDC_CURSOR'

'BSEG-ZUONR'.

perform bdc_field using 'BDC_OKCODE'

'=BU'.

perform bdc_field using 'BSEG-HKONT'

'8321006'.

perform bdc_field using 'BSEG-WRBTR'

'200'.

perform bdc_field using 'BSEG-ZFBDT'

'08.09.2006'.

perform bdc_field using 'BSEG-ZUONR'

'145876B'.

perform bdc_field using 'BSEG-SGTXT'

'A01010809062'.

PERFORM bdc_create_session.

ENDLOOP.

PERFORM bdc_close_session.

how can i write if i mentioned the next record place.

can u suggest me this problem.

answer will be rewarded.

regards

praveen

Read only

Former Member
0 Likes
624

Hi Praveen

U need not record & all, the standard program does it all for u!!, just write the incoming data in the following format on to the application server & then submit it to the std prog RFBIBL00

BGR00 - - - Session header

BBKPF - - - Header

BBSEG - - - Item

U can just go thru the documentation of the std program RFBIBL00 - - - everything is clearly mentioned there, in case of further doubts feel free to ask

Regards

Sudhir.

Read only

0 Likes
623

hi sudeer,

this is the first time iam using this type of procedure,iam little bit confuse,if u dont mine can u please send me the step by step procedure how can i proceed. and how can i write the incoming data to application server.

regards

praveen

Read only

Former Member
0 Likes
623

Hi

Check this prg.

Regards,

Raj

REPORT z_sd_gl_postings NO STANDARD PAGE HEADING

LINE-SIZE 150

MESSAGE-ID zz.

&----


  • S T R U C T U R E D E C L A R A T I O N S *

&----


TYPES: BEGIN OF x_file,

docdt(10), " Document Dt

postdt(10), " Posting Dt

ref_doc(10), " A/c doc #

doc_txt(25), " A/c doc text

account(17), " A/c of Nxt Line Itm

itm_txt(25), " Item Text

debit(8), " Debit Amount

credit(8), " Credit Amount

bus_area(4), " Business Area

END OF x_file.

TYPES: BEGIN OF x_output,

docdt(10), " Document Dt

postdt(10), " Posting Dt

ref_doc(10), " A/c doc #

account(17), " A/c of Nxt Line Itm

amount(8), " Amount

mesg(60), " Message

END OF x_output.

&----


  • I N T E R N A L T A B L E D E C L A R A T I O N S *

&----


DATA: it_file TYPE STANDARD TABLE OF x_file WITH HEADER LINE." File Data

DATA: it_out TYPE STANDARD TABLE OF x_output WITH HEADER LINE. " Outcome

DATA: bdcdata LIKE bdcdata OCCURS 0 WITH HEADER LINE.

DATA: messtab LIKE bdcmsgcoll OCCURS 0 WITH HEADER LINE.

&----


  • V A R I A B L E S D E C L A R A T I O N S *

&----


DATA : v_total TYPE i,

v_index LIKE sy-tabix.

DATA: e_group_opened.

DATA: hdate TYPE sy-datum.

&----


  • U S E R I N P U T S S C R E E N *

&----


SELECTION-SCREEN: BEGIN OF BLOCK blk01 WITH FRAME TITLE text-t01.

PARAMETERS: p_sname(12) DEFAULT 'SALESORDER',

p_uname(12) DEFAULT sy-uname,

p_file TYPE rlgrap-filename OBLIGATORY,

p_mode DEFAULT 'N'.

SELECTION-SCREEN END OF BLOCK blk01.

&----


  • I N I T I A L I Z A T I O N *

&----


INITIALIZATION.

hdate = sy-datum - 1.

CONCATENATE 'GL' sy-datum INTO p_sname.

CONDENSE p_sname NO-GAPS.

&----


  • S E L E C T I O N S C R E E N *

&----


AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.

PERFORM get_file.

AT SELECTION-SCREEN ON p_mode.

CASE p_mode.

WHEN 'A' OR 'E' OR 'N'.

WHEN OTHERS.

MESSAGE e001(zz) WITH text-e01.

ENDCASE.

&----


  • S t a r t o f S e l e c t i o n *

&----


START-OF-SELECTION.

PERFORM get_upload.

IF NOT it_file[] IS INITIAL.

PERFORM get_update. " Create G/L postings

ELSE.

MESSAGE i001(zz) WITH text-001.

ENDIF.

&----


  • E n d o f S e l e c t i o n *

&----


END-OF-SELECTION.

IF NOT it_file[] IS INITIAL.

PERFORM close_group.

PERFORM get_write.

ENDIF.

&----


*& Form get_file

&----


  • Get File name

----


FORM get_file .

CALL FUNCTION 'KD_GET_FILENAME_ON_F4'

EXPORTING

program_name = syst-repid

mask = '*'

CHANGING

file_name = p_file

EXCEPTIONS

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

ENDFORM. " get_file

&----


*& Form get_upload

&----


  • to upload the .CSV file

----


FORM get_upload .

DATA l_file TYPE string.

CLEAR: it_file, it_file[],

it_out, it_out[].

l_file = p_file.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

filename = l_file

filetype = 'ASC'

has_field_separator = 'X'

TABLES

data_tab = it_file

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.

ELSE.

SORT it_file BY docdt postdt.

ENDIF.

ENDFORM. " get_upload

&----


*& Form get_update

&----


  • Create G/L postings

----


FORM get_update .

CLEAR: v_total.

DESCRIBE TABLE it_file LINES v_total.

CLEAR: it_out, it_out[].

CLEAR: bdcdata, bdcdata[].

LOOP AT it_file.

CLEAR v_index.

v_index = sy-tabix.

AT FIRST.

READ TABLE it_file INDEX v_index.

*- Populate bdcdata

PERFORM bdc_dynpro USING 'SAPMF05A' '0100'.

PERFORM bdc_field USING 'BKPF-BLDAT' it_file-docdt.

PERFORM bdc_field USING 'BKPF-BLART' 'SA'.

PERFORM bdc_field USING 'BKPF-BUKRS' '1000'.

PERFORM bdc_field USING 'BKPF-BUDAT' it_file-postdt.

PERFORM bdc_field USING 'BKPF-MONAT' '12'.

PERFORM bdc_field USING 'BKPF-WAERS' 'INR'.

PERFORM bdc_field USING 'BKPF-XBLNR' it_file-ref_doc.

PERFORM bdc_field USING 'BKPF-BKTXT' it_file-doc_txt.

PERFORM bdc_field USING 'FS006-DOCID' '*'.

IF NOT it_file-debit IS INITIAL.

PERFORM bdc_field USING 'RF05A-NEWBS' '04'.

PERFORM bdc_field USING 'RF05A-NEWKO' it_file-account.

ELSE.

PERFORM bdc_field USING 'RF05A-NEWBS' '14'.

PERFORM bdc_field USING 'RF05A-NEWKO' it_file-account.

ENDIF.

PERFORM bdc_field USING 'BDC_OKCODE'

'/00'.

ENDAT.

PERFORM bdc_dynpro USING 'SAPMF05A' '0301'.

IF NOT it_file-debit IS INITIAL.

PERFORM bdc_field USING 'BSEG-WRBTR' it_file-debit.

ELSE.

PERFORM bdc_field USING 'BSEG-WRBTR' it_file-credit.

ENDIF.

PERFORM bdc_field USING 'BSEG-GSBER' it_file-bus_area.

  • PERFORM bdc_field USING 'BSEG-ZTERM' 'P045'.

PERFORM bdc_field USING 'BSEG-SGTXT' it_file-itm_txt.

v_index = v_index + 1.

READ TABLE it_file INDEX v_index.

IF sy-subrc = 0.

IF NOT it_file-debit IS INITIAL.

PERFORM bdc_field USING 'RF05A-NEWBS' '04'.

PERFORM bdc_field USING 'RF05A-NEWKO' it_file-account.

ELSE.

PERFORM bdc_field USING 'RF05A-NEWBS' '14'.

PERFORM bdc_field USING 'RF05A-NEWKO' it_file-account.

ENDIF.

PERFORM bdc_field USING 'BDC_OKCODE'

'/00'.

ELSE.

PERFORM bdc_field USING 'BDC_OKCODE'

'/00'.

ENDIF.

*- Populate the output table

CLEAR it_out.

it_out-docdt = it_file-docdt.

it_out-postdt = it_file-postdt.

it_out-ref_doc = it_file-ref_doc.

it_out-account = it_file-account.

IF NOT it_file-debit IS INITIAL.

it_out-amount = it_file-debit.

ELSE.

it_out-amount = it_file-credit.

ENDIF.

APPEND it_out.

CLEAR it_out.

AT LAST.

V_INDEX = V_INDEX - 1.

READ TABLE it_file INDEX v_index.

PERFORM bdc_dynpro USING 'SAPMF05A' '0301'.

IF NOT it_file-debit IS INITIAL.

PERFORM bdc_field USING 'BSEG-WRBTR' it_file-debit.

ELSE.

PERFORM bdc_field USING 'BSEG-WRBTR' it_file-credit.

ENDIF.

PERFORM bdc_field USING 'RF05A-NEWBS' '50'.

PERFORM bdc_field USING 'RF05A-NEWKO' '4250'.

PERFORM bdc_field USING 'BDC_OKCODE'

'/00'.

PERFORM bdc_dynpro USING 'SAPMF05A' '0300'.

PERFORM bdc_field USING 'BSEG-WRBTR' '*'.

PERFORM bdc_field USING 'BDC_OKCODE'

'/00'.

PERFORM bdc_dynpro USING 'SAPLKACB' '0002'.

PERFORM bdc_field USING 'COBL-GSBER' it_file-bus_area.

PERFORM bdc_field USING 'BDC_OKCODE'

'=ENTE'.

PERFORM bdc_dynpro USING 'SAPMF05A' '0300'.

  • PERFORM bdc_field USING 'BKPF-XBLNR' it_file-ref_doc.

  • PERFORM bdc_field USING 'BKPF-BKTXT' it_file-doc_txt.

PERFORM bdc_field USING 'BDC_OKCODE'

'=BU'.

PERFORM bdc_dynpro USING 'SAPLKACB' '0002'.

PERFORM bdc_field USING 'COBL-GSBER' it_file-bus_area.

PERFORM bdc_field USING 'BDC_OKCODE'

'=ENTE'.

*- Call the transaction

PERFORM bdc_transaction USING 'F-02'.

ENDAT.

ENDLOOP.

ENDFORM. " get_update

**----


    • Start new screen

**----


FORM bdc_dynpro USING program dynpro.

CLEAR bdcdata.

bdcdata-program = program.

bdcdata-dynpro = dynpro.

bdcdata-dynbegin = 'X'.

APPEND bdcdata.

ENDFORM. "bdc_dynpro

**----


    • Insert field

**----


FORM bdc_field USING fnam fval.

CLEAR bdcdata.

bdcdata-fnam = fnam.

bdcdata-fval = fval.

APPEND bdcdata.

ENDFORM. "bdc_field

**----


    • Close the group

**----


FORM close_group.

IF e_group_opened = 'X'.

CALL FUNCTION 'BDC_CLOSE_GROUP'.

IF sy-subrc EQ 0.

WRITE:/5 'Session Closed Successfully'(005).

ELSE.

WRITE:/5 'Unable to Close the session : return code'(006), sy-subrc.

ENDIF.

ENDIF.

ENDFORM. "close_group

**----


    • Start new transaction

**----


FORM bdc_transaction USING tcode.

DATA: l_mstring(480),

l_subrc LIKE sy-subrc,

l_mesg TYPE string.

DATA: l_msg_id LIKE t100-arbgb,

l_msg_no LIKE t100-msgnr,

l_msg_var1 LIKE balm-msgv1,

l_msg_var2 LIKE balm-msgv2,

l_msg_var3 LIKE balm-msgv3,

l_msg_var4 LIKE balm-msgv4.

REFRESH messtab.

CALL TRANSACTION tcode USING bdcdata

MODE p_mode

UPDATE 'S'

MESSAGES INTO messtab.

*- Populate the output table

CLEAR it_out.

*- Build the message

READ TABLE messtab WITH KEY msgtyp = 'S'.

IF sy-subrc = 0.

CONCATENATE 'Document ' messtab-msgv1 'successfully posted.' INTO l_mesg

SEPARATED BY space.

CONDENSE l_mesg.

it_out-mesg = l_mesg.

APPEND it_out.

CLEAR it_out.

ENDIF.

IF l_subrc <> 0.

IF e_group_opened = ' '.

CALL FUNCTION 'BDC_OPEN_GROUP'

EXPORTING

client = sy-mandt

group = p_sname

user = p_uname

keep = ''

holddate = hdate.

IF sy-subrc EQ 0.

WRITE:/5 'Session'(002), p_sname ,' Created Successfully'(003).

e_group_opened = 'X'.

ELSE.

WRITE:/5 'Unable to Create the session '(004), p_sname ,

'. return code', sy-subrc.

ENDIF.

ENDIF.

CALL FUNCTION 'BDC_INSERT'

EXPORTING

tcode = tcode

TABLES

dynprotab = bdcdata.

ENDIF.

REFRESH bdcdata.

CLEAR bdcdata.

ENDFORM. "bdc_transaction

&----


*& Form get_write

&----


  • Write the results

----


FORM get_write .

WRITE:/ 'Total Number of Records :'(007), v_total COLOR 1.

SKIP 3.

IF NOT it_out[] IS INITIAL.

WRITE:/5 'Doc.Dt'(010),

16 'Posting.Dt'(015),

30 'Reference Doc'(011),

45 'Account'(012),

68 'Amount'(013),

80 'Message'(014).

ENDIF.

SKIP 1.

LOOP AT it_out.

WRITE:/5 it_out-docdt,

16 it_out-postdt,

30 it_out-ref_doc,

45 it_out-account,

68 it_out-amount,

80 it_out-mesg.

ENDLOOP.

ENDFORM. " get_write