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

BDC DATASET Program required

Former Member
0 Likes
793

Hi,

I need the Program ,atleast the major code where i can do the R&D afterwards and make a full fledged program. Please help me in writing the program.

Below given is techincal document of how to proceed. I need the program for this .

<b>Technical Flow Description</b>

1. Declare internal tables similar to structures EDI 821 and EDI 824.

2. Populate these internal tables with flat file data using read dataset or gui_upload. (It depends on type of file i.e sequential file or presentation file)

3. Get the document number (PAYR-VBLNR), Company code (PAYR-ZBUKR) and Fiscal year (PAYR-GJAHR) from table PAYR into t_tab1 based on check number in the flat file.

4. Get the number of line items (BSEG-BUZEI) and posting key (BSEG-BSCHL) for accounting document based on internal table t_tab1.

5. Take the posting key as 25.

6. Do the recording for Transaction FB02.

7. If flat file has Record name 'BANK_NOTES' IF CHECK_NUMBER of CHECK_ADVICE of the flat file = BSEG-CHECT then insert NOTES of BANK_NOTES of Flat file into BSEG-SGTXT

8. If flat file has Record name 'BANK_NOTES' IF CHECK_NUMBER of CHECK_ADVICE of the flat file = BSEG-CHECT. Then update SAP field BSEG-XREF2 .

9. When Flat file check Number = PAYR-CHECT then Insert Flat file RECEIPT_DATE into SAP field BSEG-XREF1. Then update SAP fields BSEG-XREF1, BSEG-XREF2 and BSEG-SGTXT using BDC call transaction ‘FB02’.

DATA : BEGIN OF T_ED824 OCCURS 1,

PAY_ADVICE_HDR(30) TYPE C,

CUST_REF(30) TYPE C,

PROCESSED_DATE(10) TYPE C,

PROCESSED_TIME(5) TYPE C,

PAYMENT_ADVICE(30) TYPE C,

PAYADVICE_TYPE(3) TYPE C,

PAYADVICE_CODE(3) TYPE C,

PAYEDBACH(15) TYPE C,

TRACE_NUMBER(30) TYPE C,

BATCH_AMOUNT(18) TYPE C,

ACCEPT_AMOUNT(18) TYPE C,

BANK_AMOUNT(18) TYPE C,

REJECT_AMOUNT(18) TYPE C,

BATCH_COUNT(15) TYPE C,

ACCEPT_COUNT(15) TYPE C,

BANK_COUNT(15) TYPE C,

REJECT_COUNT(15) TYPE C,

ADVICE_DESC(30) TYPE C,

BANK_NOTES(30) TYPE C,

B_TYPE(3) TYPE C,

B_NOTES(60) TYPE C,

CHECK_ADVICE(30) TYPE C,

CHKADVICE_TYPE(3) TYPE C,

CHKADVICE_CODE(10) TYPE C,

CHECK_NUMBER(10) TYPE C,

CHECK_NOTES(30) TYPE C,

C_TYPE(3) TYPE C,

C_NOTES(60) TYPE C,

END OF T_ED824.

DATA : BEGIN OF T_ED821 OCCURS 1,

PAY_REPORT_HDR(30) TYPE C,

REPORT_TYPE(5) TYPE C,

RECEIPT_DATE(10) TYPE C,

CURRENT_DATE(10) TYPE C,

PAY_REPORT(30) TYPE C,

CUST_ACCT_NUM(35) TYPE C,

ISSUE_DATE(10) TYPE C,

TRANSAC_AMOUNT TYPE C,

CHECK_NUMBER(20) TYPE C,

PAYEE_NAME(50) TYPE C,

FINANCIAL_CODE(30) TYPE C,

CHECK_CODE(3) TYPE C,

INST_NAME(35) TYPE C,

END OF T_ED821.

2 REPLIES 2
Read only

Former Member
0 Likes
596

check this prog :

-


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

  • Includes *

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

include bdcrecx1.

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

  • Tables *

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

tables: sscrfields.

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

  • Types *

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

types: begin of ty_pcdata,

data(250),

end of ty_pcdata,

begin of ty_upload,

mandt like ska1-mandt, "client

ktopl like ska1-ktopl, "chart of account

saknr like skb1-saknr, "GL Account

txt20 like skat-txt20 , "Short text.

txt50 like skat-txt50 , "Long text

mcod1 like ska1-mcod1, "search term

xbilk type c, "Balance Sheet account = X

xplacct type c, "P&L account = X

ktoks like ska1-ktoks, "account type

fdlev like skb1-fdlev, "Planning level

fipls like skb1-fipls, "fin budget

fstag like skb1-fstag, "Field status group

kdfsl like skb1-kdfsl, "Exchange rate diff

mitkz like skb1-mitkz, "recon. acct for acct type

mwskz like skb1-mwskz, "tax category

waers like skb1-waers, "Currency

xgkon like skb1-xgkon, "relevant to cash flow

xintb like skb1-xintb, "Post automatically only = X

xkres like skb1-xkres, "line item display = X

xopvw like skb1-xopvw, "open item management = X

xspeb like skb1-xspeb, "posting block

znirt like skb1-vzskz, "int.calc.freq

zuawa like skb1-zuawa, "sort

altkt like skb1-altkt, "alternative account no

xsalh like skb1-xsalh, "balanve in local currency

  • xmwno like skb1-xmwno , "tax not required

bukrs like skb1-bukrs, "Company no

end of ty_upload.

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

  • Internal Tables *

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

data: t_pcdata type ty_pcdata occurs 0,

t_upload type ty_upload occurs 0.

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

  • Variable data *

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

data: v_pcdata type ty_pcdata,

v_upload type ty_upload,

v_path like usr05-parva,

v_date(10) type c,

v_file type string,

v_filler(30) type c.

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

  • Constants *

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

constants: c_sep type x value '09', "

c_keep_session like apqi-qerase value 'X'.

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

  • Parameters *

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

parameters:

p_file(60). " LIKE rfpdo-rfbifile.

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

  • Initialization *

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

initialization.

group = 'FS00NEW'.

e_group = 'FS00ERR'.

keep = 'X'.

ctumode = 'E'.

cupdate = 'S'.

e_keep = 'X'.

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

  • Help on filename *

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

at selection-screen on value-request for p_file.

select single parva

into v_path

from usr05

where bname = sy-uname

and parid = 'GR8'.

if sy-subrc <> 0.

v_path = 'H:\'.

endif.

call function 'WS_FILENAME_GET'

exporting

def_filename = p_file

def_path = v_path "'H:\'

mask = ',.txt,.txt.'

mode = '0'

title = 'Output file'

importing

filename = p_file

exceptions

others = 1.

if sy-subrc <> 0.

message e000 with 'Unable to find file.'.

endif.

*AT SELECTION-SCREEN.

  • case SSCRFIELDS-UCOMM.

  • when 'ONLI' or 'PRIN'. "Only process if action key hit

  • PERFORM upload_file.

  • when others.

  • endcase.

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

  • Main processing *

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

start-of-selection.

perform upload_file.

perform extract_data.

perform open_group.

loop at t_upload into v_upload.

    • skip if header line

if v_upload-bukrs+2(1) cn '0123456789'.

continue.

endif.

    • start screen

perform bdc_dynpro using 'SAPLGL_ACCOUNT_MASTER_MAINTAIN' '2001'.

perform bdc_field using:

'BDC_OKCODE' '=ACC_CRE',

'GLACCOUNT_SCREEN_KEY-SAKNR' v_upload-saknr,

'GLACCOUNT_SCREEN_KEY-BUKRS' v_upload-bukrs.

perform bdc_dynpro using 'SAPLGL_ACCOUNT_MASTER_MAINTAIN' '2001'.

perform bdc_field using:

'BDC_OKCODE' '=TAB02',

'GLACCOUNT_SCREEN_COA-KTOKS' v_upload-ktoks,

'GLACCOUNT_SCREEN_COA-XPLACCT' v_upload-xplacct,

'GLACCOUNT_SCREEN_COA-XBILK' v_upload-xbilk,

'GLACCOUNT_SCREEN_COA-TXT20_ML' v_upload-txt20,

'GLACCOUNT_SCREEN_COA-TXT50_ML' v_upload-txt50.

write v_upload-zuawa to v_upload-zuawa right-justified.

translate v_upload-zuawa using ' 0'.

perform bdc_dynpro using 'SAPLGL_ACCOUNT_MASTER_MAINTAIN' '2001'.

perform bdc_field using:

'BDC_OKCODE' '=TAB03',

'GLACCOUNT_SCREEN_CCODE-WAERS' v_upload-waers,

'GLACCOUNT_SCREEN_CCODE-XSALH' v_upload-xsalh,

'GLACCOUNT_SCREEN_CCODE-MWSKZ' v_upload-mwskz,

'GLACCOUNT_SCREEN_CCODE-XKRES' v_upload-xkres,

'GLACCOUNT_SCREEN_CCODE-ZUAWA' v_upload-zuawa.

case v_upload-ktoks.

when 'AS' or 'CASH' or 'GL' or 'MAT'.

perform bdc_field using:

'GLACCOUNT_SCREEN_CCODE-XOPVW' v_upload-xopvw.

when 'AS' or 'CASH' or 'GL'.

perform bdc_field using:

'GLACCOUNT_SCREEN_CCODE-MITKZ' v_upload-mitkz.

endcase.

perform bdc_dynpro using 'SAPLGL_ACCOUNT_MASTER_MAINTAIN' '2001'.

perform bdc_field using:

'BDC_OKCODE' '=SAVE',

'GLACCOUNT_SCREEN_CCODE-FSTAG' v_upload-fstag,

'GLACCOUNT_SCREEN_CCODE-XINTB' v_upload-xintb,

'GLACCOUNT_SCREEN_CCODE-FDLEV' v_upload-fdlev.

case v_upload-ktoks.

when 'CASH' or 'GL'.

perform bdc_field using:

'GLACCOUNT_SCREEN_CCODE-XGKON' v_upload-xgkon.

endcase.

perform bdc_transaction using 'FS00'.

clear bdcdata.

endloop.

perform close_group.

skip 2.

format hotspot on color 5.

write: 'Click here to run transaction SM35'.

format hotspot off.

format color off.

skip.

----


  • FORM upload_file *

----


  • Upload the text file from the PC *

----


form upload_file.

v_file = p_file.

call function 'GUI_UPLOAD'

exporting

filename = v_file

filetype = 'ASC'

tables

data_tab = t_pcdata

exceptions

file_open_error = 1

file_read_error = 2

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.

case sy-subrc.

when 1.

message e000 with 'Incorrect filename or the file is in use'.

when 2.

message e000 with 'Problem reading the file'.

when 5.

message e000 with 'Incorrect file type'.

when others.

message e000 with 'Problem with the selected file'.

endcase.

endif.

endform.

----


  • FORM extract_data *

----


  • Extract the data from the uploaded file into useable table *

----


form extract_data.

loop at t_pcdata into v_pcdata.

split v_pcdata at c_sep into

  • v_upload-saknr

  • v_upload-bukrs

  • v_upload-ktoks

  • v_upload-xplacct

  • v_upload-xbilk

  • v_upload-txt20

  • v_upload-txt50

  • v_upload-xmwno

  • v_upload-xopvw

  • v_upload-xkres

  • v_upload-altkt

  • v_upload-zuawa

  • v_upload-waers

  • v_upload-fstag

  • v_upload-fdlev

  • v_upload-xintb

  • v_upload-xintb

  • v_upload-xgkon

  • v_upload-mitkz

  • v_upload-mwskz

  • v_filler.

*

v_upload-mandt

v_upload-ktopl

v_upload-saknr

v_upload-txt20

v_upload-txt50

v_upload-mcod1

v_upload-xbilk

v_upload-xplacct

v_upload-ktoks

v_upload-fdlev

v_upload-fipls

v_upload-fstag

v_upload-kdfsl

v_upload-mitkz

v_upload-mwskz

v_upload-waers

v_upload-xgkon

v_upload-xintb

v_upload-xkres

v_upload-xopvw

v_upload-xspeb

v_upload-znirt

v_upload-zuawa

v_upload-altkt

v_upload-xsalh

  • v_upload-xmwno

v_upload-bukrs

v_filler.

  • if v_upload-xbilk = 'X'.

  • clear v_upload-xplacct.

  • else.

  • v_upload-xplacct = 'X'.

  • endif.

append v_upload to t_upload.

endloop.

endform.

-


Rewards points if helpfull

Regads,

Vind

Read only

Former Member
0 Likes
596

Hi

see the sample code for uploading from Application server while doing BDC

report ZSDBDCP_PRICING no standard page heading

line-size 255.

include zbdcrecx1.

*--Internal Table To hold condition records data from flat file.

Data: begin of it_pricing occurs 0,

key(4),

f1(4),

f2(4),

f3(2),

f4(18),

f5(16),

end of it_pricing.

*--Internal Table To hold condition records header .

data : begin of it_header occurs 0,

key(4),

f1(4),

f2(4),

f3(2),

end of it_header.

*--Internal Table To hold condition records details .

data : begin of it_details occurs 0,

key(4),

f4(18),

f5(16),

end of it_details.

data : v_sno(2),

v_rows type i,

v_fname(40).

start-of-selection.

refresh : it_pricing,it_header,it_details.

clear : it_pricing,it_header,it_details.

  • CALL FUNCTION 'UPLOAD'

  • EXPORTING

  • FILENAME = 'C:\WINDOWS\Desktop\pricing.txt'

  • FILETYPE = 'DAT'

  • TABLES

  • DATA_TAB = it_pricing

  • EXCEPTIONS

  • CONVERSION_ERROR = 1

  • INVALID_TABLE_WIDTH = 2

  • INVALID_TYPE = 3

  • NO_BATCH = 4

  • UNKNOWN_ERROR = 5

  • GUI_REFUSE_FILETRANSFER = 6

  • OTHERS = 7.

WRITE : / 'Condition Records ', P_FNAME, ' on ', SY-DATUM.

OPEN DATASET P_FNAME FOR INPUT IN TEXT MODE.

if sy-subrc ne 0.

write : / 'File could not be uploaded.. Check file name.'.

stop.

endif.

CLEAR : it_pricing[], it_pricing.

DO.

READ DATASET P_FNAME INTO V_STR.

IF SY-SUBRC NE 0.

EXIT.

ENDIF.

  • write v_str.

  • translate v_str using '#/'.

SPLIT V_STR AT ',' INTO it_pricing-key

it_pricing-F1 it_pricing-F2 it_pricing-F3

it_pricing-F4 it_pricing-F5 .

APPEND it_pricing.

CLEAR it_pricing.

ENDDO.

IF it_pricing[] IS INITIAL.

WRITE : / 'No data found to upload'.

STOP.

ENDIF.

loop at it_pricing.

At new key.

read table it_pricing index sy-tabix.

move-corresponding it_pricing to it_header.

append it_header.

clear it_header.

endat.

move-corresponding it_pricing to it_details.

append it_details.

clear it_details.

endloop.

perform open_group.

v_rows = sy-srows - 8.

loop at it_header.

perform bdc_dynpro using 'SAPMV13A' '0100'.

perform bdc_field using 'BDC_CURSOR'

'RV13A-KSCHL'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'RV13A-KSCHL'

it_header-f1.

perform bdc_dynpro using 'SAPMV13A' '1004'.

perform bdc_field using 'BDC_CURSOR'

'KONP-KBETR(01)'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'KOMG-VKORG'

it_header-f2.

perform bdc_field using 'KOMG-VTWEG'

it_header-f3.

**Table Control

v_sno = 0.

loop at it_details where key eq it_header-key.

v_sno = v_sno + 1.

clear v_fname.

CONCATENATE 'KOMG-MATNR(' V_SNO ')' INTO V_FNAME.

perform bdc_field using v_fname

it_details-f4.

clear v_fname.

CONCATENATE 'KONP-KBETR(' V_SNO ')' INTO V_FNAME.

perform bdc_field using v_fname

it_details-f5.

if v_sno eq v_rows.

v_sno = 0.

perform bdc_dynpro using 'SAPMV13A' '1004'.

perform bdc_field using 'BDC_OKCODE'

'=P+'.

perform bdc_dynpro using 'SAPMV13A' '1004'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

endif.

endloop.

*--Save

perform bdc_dynpro using 'SAPMV13A' '1004'.

perform bdc_field using 'BDC_OKCODE'

'=SICH'.

perform bdc_transaction using 'VK11'.

endloop.

perform close_group.

Regards

Anji