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

Regarding BDC

Former Member
0 Likes
408

Hi,

can anybody please help me in transferring data through BDC direct input method?

2 REPLIES 2
Read only

Former Member
0 Likes
379

See the following ex: for RFBIBL00

DATA: BEGIN OF bgr00. "BI strucutre in RFBIBL00

INCLUDE STRUCTURE bgr00.

DATA: END OF bgr00.

DATA: BEGIN OF bbkpf. " Header Structure in RFBIBL00

INCLUDE STRUCTURE bbkpf.

DATA: END OF bbkpf.

DATA: BEGIN OF bbseg. " Line Item Structure in RFBIBL00

INCLUDE STRUCTURE bbseg.

DATA: END OF bbseg.

*File in Application Server

DATA: output_file_name LIKE rfpdo-rfbifile VALUE 'J:\EXCER'.

*Data declaration for passing values to screen of RFBIBL00

DATA: callmode VALUE 'B', "BDC MODE

max_comm(4) VALUE '1000', "COMMIT

pa_xprot, “

anz_mode LIKE rfpdo-allgazmd VALUE 'N', “Display Mode

update LIKE rfpdo-allgvbmd VALUE 'S', “ Update Mode

tab1 TYPE i,

in_tab TYPE i,

fl_check,

flag TYPE c.

CONSTANTS: exp_acc(3) VALUE '800'.

DATA: BEGIN OF itab1 OCCURS 0,

bldat LIKE bkpf-bldat,

blart LIKE bkpf-blart, “Document Type

bukrs LIKE bkpf-bukrs, “Company Code

budat LIKE bkpf-budat,

waers LIKE bkpf-waers, “Currency Key

bschl LIKE bseg-bschl, “posting Key

hkont LIKE bseg-hkont, “Account Number

wrbtr(17) TYPE c, “Transactional Amount

sgtxt LIKE bseg-sgtxt, “Text

END OF itab1.

DATA: itab LIKE itab1 OCCURS 0 WITH HEADER LINE,

wa_itab LIKE itab1.

SELECTION-SCREEN: BEGIN OF BLOCK blk.

PARAMETERS: fname TYPE rlgrap-filename,

poutput LIKE rfpdo1-f05xicpd DEFAULT 'PAY',

pgroup LIKE bgr00-group DEFAULT 'FBPRAC',

pusnam LIKE bgr00-usnam DEFAULT sy-uname,

pxkeep LIKE bgr00-xkeep DEFAULT 'X',

pstart LIKE bgr00-start DEFAULT space,

ptcode LIKE blf00-tcode DEFAULT 'FB01',

XLOG(1) TYPE C DEFAULT 'X'.

SELECTION-SCREEN: END OF BLOCK blk.

  • Select File to upload data into internal table

AT SELECTION-SCREEN ON VALUE-REQUEST FOR fname.

CALL FUNCTION 'F4_FILENAME'

EXPORTING

program_name = 'ZRFBIB_CONV'

dynpro_number = '1000'

field_name = 'FNAME'

IMPORTING

file_name = fname.

START-OF-SELECTION.

*Upload data from legacy to itab

PERFORM upload_data.

  • Open App File

OPEN DATASET output_file_name FOR OUTPUT IN TEXT MODE.

IF sy-subrc <> 0.

WRITE:/ 'FILE COULD NOT BE OPENED'.

ENDIF.

  • Populate data into bgr00 structure

PERFORM populate_bgr00.

*Load data

PERFORM load_data.

&----


*& Form upload_data

&----


FORM upload_data.

CALL FUNCTION 'WS_UPLOAD'

EXPORTING

filename = fname

filetype = 'DAT'

TABLES

data_tab = itab1

ENDFORM. " upload_data

&----


*& Form populate_bgr00

&----


  • Subroutine to populate data in bgr00 structure

----


FORM populate_bgr00.

bgr00-stype = '0'. "BI Record

bgr00-group = pgroup. "BDC Group

bgr00-mandt = sy-mandt. "Client

bgr00-usnam = pusnam. "User Id

bgr00-start = pstart. "Queue Start Date

bgr00-xkeep = pxkeep. "Keep Session

bgr00-nodata = '/'.

TRANSFER bgr00 TO output_file_name.

ENDFORM. " populate_bgr00

&----


*& Form load_data

&----


  • Actual load logic start in this subroutine

----


FORM load_data.

LOOP AT itab1.

REFRESH itab.

***For the purpose of reconciliation,split the bschl and HKONT into 2

***line items

MOVE-CORRESPONDING: itab1 TO wa_itab.

APPEND wa_itab TO itab.

**For the purpose of reconciliation,do as below

IF wa_itab-bschl = '50'.

wa_itab-bschl = '40'.

ELSE.

wa_itab-bschl = '50'.

ENDIF.

APPEND wa_itab TO itab.

READ TABLE itab INDEX 1.

*populate data in bbkpf

PERFORM populate_bbkpf.

LOOP AT itab.

*populate data in bbseg.

PERFORM populate_bbseg.

ENDLOOP.

CLEAR: itab, itab1.

*Submit to program rfbibl00

SUBMIT rfbibl00 WITH ds_name = output_file_name "File name

WITH fl_check = fl_check "File check

WITH callmode = callmode "BDC Mode

WITH max_comm = max_comm "Max Commit

WITH pa_xprot = pa_xprot "Extended Log

WITH anz_mode = anz_mode " Display Mode

WITH update = update "Update Mode

WITH XLOG = XLOG "Display Log

AND RETURN.

ENDLOOP.

ENDFORM. " load_data

&----


*& Form populate_bbkpf

&----


  • text

----


FORM populate_bbkpf.

TRANSLATE bbkpf USING ' /'.

bbkpf-stype = '1'. " BI Interface Record

bbkpf-tcode = ptcode. " Transaction Code

bbkpf-bldat = '31122004'. " Document Date

bbkpf-budat = '31122004'. " Posting Date

bbkpf-blart = itab-blart. " Document Type

bbkpf-bukrs = itab-bukrs. " Company Code

bbkpf-waers = itab-waers. " Currency

  • BBKPF-XBLNR = 'PAYROLL'. " Reference Document

bbkpf-sende = '/'. " Record End Indicator

TRANSFER bbkpf TO output_file_name. "Transfer to App Server File

ENDFORM. " populate_bbkpf

&----


*& Form populate_bbseg

&----


FORM populate_bbseg.

CLEAR bbseg.

TRANSLATE bbseg USING ' /'.

*Document Detail For Accounting Document

bbseg-stype = '2'. "Batch Input Interface Record

bbseg-tbnam = 'BBSEG'.

bbseg-wrbtr = itab-wrbtr. "Amount in Local Currency

bbseg-sgtxt = itab-sgtxt. "Line Item Text

bbseg-newbs = itab-bschl. "Posting Key for Next Line

bbseg-newko = itab-hkont.

bbseg-sende = '/'. "Record End Indicator

TRANSFER bbseg TO output_file_name. “Transfer data from itab to App file

ENDFORM. " populate_bbseg

Read only

Former Member
0 Likes
379

To use the Direct Input method, you need to first identify the Standard program for the direct input.

The Standard program will be a report which expects the data to be in a particular format to be uploaded. It should be passed with a file location where the file in the required format is to be placed. Once you pplace the file in that location and run the standard report, the Direct input is said to be done and the database tables will get uploaded.

The part you have to do is , to upload the file from either an application server or a presentation server, and format into the required format in which the direct input program expects and place the file in the target location on the application server and finally submit the direct input standard program.

Regards,

Ravi