Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Problem in bdc

Dear Friends

I am working with FI BDC Tcode FS00,

in that program it was (X) was comming in wrong place how can i finde what this was comming 4m bdc programing

&----


*& Report ZDHBVN_FI_FSOO

*&

&----


*&

*&

&----


REPORT ZDHBVN_FI_FSOO NO STANDARD PAGE HEADING

LINE-SIZE 150

LINE-COUNT 60 .

----


  • DATA DECLARATIONS *

----


DATA : BEGIN OF t_data OCCURS 0,

  • data element: SAKNR " G/L Account

saknr(010),

  • data element: BUKRS " Company Code

bukrs(004),

  • data element: KTOKS " Account Group

ktoks(004),

  • data element: XPLACCT, " P&L statement acct radio button

xplacct(001),

    • data element: XBILK " Balance Sheet acct radio button

xbilk(001),

  • data element: TXT20_ML " Short Text

txt20(020),

  • data element: TXT50_ML " Long Text

txt50(050),

  • data element: WAERS " Currency

waers(005),

  • data element:XSALH " Indicator manage local currency

xsalh(001),

  • data element: MWSKZ " Indicator manage local currency

mwskz(002),

  • data element: XMWNO " Posting Key without tax allowed

xmwno(001),

  • data element: MITKZ " Recouncillation acct type

MITKZ(001),

  • data element: XOPVW " Open item management

xopvw(001),

  • data element: XKRES " Line item display

xkres(001),

  • data element: ZUAWA " sort key

zuawa(003),

  • data element: FSTAG " Field status group

fstag(004),

  • data element: XINTB " Indictor posted automatically

xintb(001),

  • data element: XGKON " Relevant Cash

xgkon(001),

  • data element: HBKID " House Bank

hbkid(005),

  • data element: HKTID " Account ID

hktid(005),

END OF t_data.

DATA BEGIN OF t_invalid_data OCCURS 0.

INCLUDE STRUCTURE t_data.

DATA : reason(70),

END OF t_invalid_data.

DATA : BEGIN OF t_dynvalue OCCURS 0.

INCLUDE STRUCTURE dynpread.

DATA : END OF t_dynvalue.

DATA : t_excel_data TYPE alsmex_tabline

OCCURS 0 WITH HEADER LINE.

DATA : BEGIN OF t_unixdata OCCURS 0,

char(100),

END OF t_unixdata.

DATA : BEGIN OF w,

format(25) VALUE ',.,..',

fieldvalue,

text01(30),

message(60),

line01(132),

line02 LIKE w-line01,

line03 LIKE w-line01,

filename TYPE string,

count TYPE i,

index LIKE sy-tabix,

END OF w.

DATA : t_bdcdata LIKE bdcdata OCCURS 0 WITH HEADER LINE,

t_bdcmsg LIKE bdcmsgcoll OCCURS 0 WITH HEADER LINE,

bdc_mode VALUE 'A'.

----


  • Selections/parameters *

----


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

SELECTION-SCREEN SKIP 1.

PARAMETER : p_file LIKE rlgrap-filename OBLIGATORY,

p_pc RADIOBUTTON GROUP gr1,

p_unix RADIOBUTTON GROUP gr1.

SELECTION-SCREEN END OF BLOCK b1.

----


  • INITIALIZATION *

----


INITIALIZATION.

----


  • AT SELECTION-SCREEN *

----


AT SELECTION-SCREEN ON BLOCK b1.

IF NOT p_pc IS INITIAL.

IF NOT p_file IS INITIAL AND ( p_file1(2) <> ':\' OR p_file0(1)

CN 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz' ).

MESSAGE e000(0k) WITH 'Enter a valid PC file name'.

ENDIF.

ELSE.

IF NOT p_file IS INITIAL AND p_file CA ':\'.

MESSAGE e000(0k) WITH 'Enter a valid UNIX file name'.

ENDIF.

ENDIF.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.

PERFORM read_screenvalue.

IF NOT w-fieldvalue IS INITIAL.

PERFORM get_filename.

ELSE.

MESSAGE i000(0k) WITH 'File selection not available for UNIX.'.

ENDIF.

AT SELECTION-SCREEN.

PERFORM read_screenvalue.

IF sy-ucomm EQ 'SJOB' AND NOT w-fieldvalue IS INITIAL.

MESSAGE e000(0k) WITH 'File can not be uploaded from presentation'

'server while executing in background'.

ENDIF.

----


  • TOP-OF-PAGE *

----


TOP-OF-PAGE.

----


  • START-OF-SELECTION *

----


START-OF-SELECTION.

PERFORM upload_data_to_internal_table.

PERFORM filter_uploaded_data.

PERFORM upload_data.

END-OF-SELECTION.

PERFORM write_failed_data .

&----


*& Form get_filename

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM get_filename .

CALL FUNCTION 'WS_FILENAME_GET'

EXPORTING

def_path = 'C:\'

mask = w-format

mode = 'O'

title = 'Open File '

IMPORTING

filename = p_file

EXCEPTIONS

inv_winsys = 1

no_batch = 2

selection_cancel = 3

selection_error = 4

OTHERS = 5.

IF sy-subrc <> 0 AND sy-subrc <> 3.

MESSAGE i000(0k) WITH 'Filename get (F4) not available.'.

ENDIF.

ENDFORM. " get_filename

&----


*& Form read_screenvalue

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM read_screenvalue .

CLEAR : t_dynvalue.

REFRESH : t_dynvalue.

MOVE 'P_PC' TO t_dynvalue-fieldname.

APPEND t_dynvalue.

CLEAR : t_dynvalue.

MOVE 'P_UNIX' TO t_dynvalue-fieldname.

APPEND t_dynvalue.

CALL FUNCTION 'DYNP_VALUES_READ'

EXPORTING

dyname = sy-repid

dynumb = sy-dynnr

TABLES

dynpfields = t_dynvalue

EXCEPTIONS

invalid_abapworkarea = 1

invalid_dynprofield = 2

invalid_dynproname = 3

invalid_dynpronummer = 4

invalid_request = 5

no_fielddescription = 6

invalid_parameter = 7

undefind_error = 8

double_conversion = 9

stepl_not_found = 10

OTHERS = 11.

IF sy-subrc = 0.

READ TABLE t_dynvalue INDEX 1.

IF sy-subrc EQ 0.

MOVE t_dynvalue-fieldvalue TO w-fieldvalue.

ENDIF.

ENDIF.

ENDFORM. " read_screenvalue

&----


*& Form upload_data_to_internal_table

&----


  • Subroutine for upload data internal table

----


  • --> p1 text

  • <-- p2 text

----


FORM upload_data_to_internal_table .

IF NOT p_pc IS INITIAL.

      • Code to upload data from PC

CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'

EXPORTING

filename = p_file

i_begin_col = 1

i_begin_row = 1

i_end_col = 30

i_end_row = 65300

TABLES

intern = t_excel_data

EXCEPTIONS

inconsistent_parameters = 1

upload_ole = 2

OTHERS = 3.

IF sy-subrc <> 0.

MESSAGE i000(0k) WITH 'Error in uploading file. Returncode'

sy-subrc.

ENDIF.

SORT t_excel_data BY row col.

LOOP AT t_excel_data.

IF t_excel_data-row GE 2. "To ignore header line of file

CASE t_excel_data-col.

WHEN 1.

t_data-saknr = t_excel_data-value.

WHEN 2.

t_data-ktoks = t_excel_data-value.

WHEN 3.

t_data-xplacct = t_excel_data-value.

WHEN 4.

t_data-xbilk = t_excel_data-value.

WHEN 5.

t_data-txt20 = t_excel_data-value.

WHEN 6.

t_data-txt50 = t_excel_data-value.

WHEN 7.

t_data-xsalh = t_excel_data-value.

WHEN 8.

t_data-mwskz = t_excel_data-value.

WHEN 9.

t_data-xmwno = t_excel_data-value.

WHEN 10.

T_DATA-MITKZ = T_EXCEL_DATA-VALUE.

WHEN 11.

t_data-xopvw = t_excel_data-value.

WHEN 12.

t_data-zuawa = t_excel_data-value.

WHEN 13.

t_data-fstag = t_excel_data-value.

WHEN 14.

t_data-xintb = t_excel_data-value.

WHEN 15.

t_data-xgkon = t_excel_data-value.

WHEN 16.

t_data-hbkid = t_excel_data-value.

WHEN 17.

t_data-hktid = t_excel_data-value.

CLEAR : t_excel_data.

ENDCASE.

AT END OF row.

t_data-bukrs = 'BP01'.

APPEND t_data.

CLEAR t_data.

ENDAT.

CLEAR : t_excel_data.

ENDIF.

ENDLOOP.

DESCRIBE TABLE t_data LINES w-count.

IF w-count IS INITIAL.

MESSAGE e000(0k) WITH 'No data to process from the flat file.'.

STOP.

ENDIF.

ELSE.

      • Code to upload that from UNIX

CLEAR : w-count.

OPEN DATASET p_file FOR INPUT IN TEXT MODE ENCODING DEFAULT

MESSAGE w-message.

IF sy-subrc <> 0.

SKIP 2.

WRITE :/10 'Error in opening file from UNIX.'.

WRITE :/10 w-message.

WRITE :/10 'Filename with path', p_file(100).

STOP.

ENDIF.

DO.

CLEAR t_data.

READ DATASET p_file INTO t_unixdata.

IF sy-subrc <> 0.

EXIT.

ENDIF.

APPEND t_unixdata.

ENDDO.

CLOSE DATASET p_file.

LOOP AT t_unixdata.

IF sy-tabix GT 1. "To ignore header line of file

SPLIT t_unixdata-char AT ',' INTO t_data-saknr

t_data-bukrs

t_data-ktoks

t_data-xplacct

t_data-xbilk

t_data-waers

t_data-xsalh

t_data-mwskz

t_data-xmwno

t_data-xopvw

t_data-xkres

t_data-zuawa

t_data-fstag

t_data-xintb

t_data-xgkon

t_data-hbkid

t_data-hktid.

APPEND t_data.

CLEAR t_data.

ENDIF.

ENDLOOP.

CLEAR : w-count.

DESCRIBE TABLE t_data LINES w-count.

IF w-count IS INITIAL.

MESSAGE e000(0k) WITH 'No data to process from the flat file.'.

STOP.

ENDIF.

ENDIF.

ENDFORM. " upload_data_to_internal_table

&----


*& Form filter_uploaded_data

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM filter_uploaded_data .

  • LOOP AT T_DATA.

  • W-INDEX = SY-TABIX.

  • ENDLOOP.

ENDFORM. " filter_uploaded_data

&----


*& Form upload_data

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM upload_data .

LOOP AT t_data.

PERFORM fill_bdc_structure.

PERFORM bdc_transaction.

ENDLOOP.

ENDFORM. " upload_data

&----


*& Form fill_bdc_structure

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM fill_bdc_structure .

REFRESH: t_bdcdata,

t_bdcmsg.

*First Screen ( Type / Description )

perform bdc_dynpro using 'SAPLGL_ACCOUNT_MASTER_MAINTAIN' '2001'.

perform bdc_field using 'BDC_OKCODE'

'=ACC_CRE'.

perform bdc_field using 'BDC_CURSOR'

'GLACCOUNT_SCREEN_KEY-SAKNR'.

perform bdc_field using 'GLACCOUNT_SCREEN_KEY-SAKNR'

t_data-saknr.

perform bdc_field using 'GLACCOUNT_SCREEN_KEY-BUKRS'

'BP01'.

perform bdc_dynpro using 'SAPLGL_ACCOUNT_MASTER_MAINTAIN' '2001'.

perform bdc_field using 'BDC_OKCODE'

'=2102_GROUP'.

perform bdc_field using 'BDC_CURSOR'

'GLACCOUNT_SCREEN_COA-KTOKS'.

perform bdc_field using 'GLACCOUNT_SCREEN_COA-KTOKS'

t_data-ktoks.

perform bdc_field using 'GLACCOUNT_SCREEN_COA-XPLACCT'

'X'.

perform bdc_dynpro using 'SAPLGL_ACCOUNT_MASTER_MAINTAIN' '2001'.

perform bdc_field using 'BDC_OKCODE'

'=TAB02'.

perform bdc_field using 'GLACCOUNT_SCREEN_COA-KTOKS'

t_data-ktoks.

if t_data-ktoks = 'PL' .

perform bdc_field using 'GLACCOUNT_SCREEN_COA-XPLACCT'

'X'.

elseif t_data-ktoks = 'pl'.

perform bdc_field using 'GLACCOUNT_SCREEN_COA-XPLACCT'

'X'.

endif.

if t_data-ktoks = 'AS'.

perform bdc_field using 'GLACCOUNT_SCREEN_COA-XBILK'

  • 'X'.

t_data-xbilk.

elseif t_data-ktoks = 'GL'.

perform bdc_field using 'GLACCOUNT_SCREEN_COA-XBILK'

  • 'X'.

t_data-xbilk.

elseif t_data-ktoks = 'AS'.

perform bdc_field using 'GLACCOUNT_SCREEN_COA-XBILK'

t_data-xbilk.

endif.

perform bdc_field using 'BDC_CURSOR'

'GLACCOUNT_SCREEN_COA-TXT50_ML'.

perform bdc_field using 'GLACCOUNT_SCREEN_COA-TXT20_ML'

t_data-txt20.

perform bdc_field using 'GLACCOUNT_SCREEN_COA-TXT50_ML'

t_data-txt50.

perform bdc_dynpro using 'SAPLGL_ACCOUNT_MASTER_MAINTAIN' '2001'.

perform bdc_field using 'BDC_OKCODE'

'=TAB03'.

perform bdc_field using 'GLACCOUNT_SCREEN_CCODE-WAERS'

'INR'.

perform bdc_field using 'GLACCOUNT_SCREEN_CCODE-XSALH'

t_data-xsalh.

perform bdc_field using 'GLACCOUNT_SCREEN_CCODE-MWSKZ'

t_data-mwskz.

if t_data-xmwno = 'X'.

perform bdc_field using 'GLACCOUNT_SCREEN_CCODE-XMWNO'

'X'.

endif.

perform bdc_field using 'GLACCOUNT_SCREEN_CCODE-MITKZ'

t_data-mitkz.

perform bdc_field using 'BDC_CURSOR'

'GLACCOUNT_SCREEN_CCODE-ZUAWA'.

perform bdc_field using 'GLACCOUNT_SCREEN_CCODE-XKRES'

'X'.

perform bdc_field using 'GLACCOUNT_SCREEN_CCODE-ZUAWA'

t_data-zuawa.

perform bdc_dynpro using 'SAPLGL_ACCOUNT_MASTER_MAINTAIN' '2001'.

perform bdc_field using 'BDC_OKCODE'

'=SAVE'.

perform bdc_field using 'BDC_CURSOR'

'GLACCOUNT_SCREEN_CCODE-FSTAG'.

perform bdc_field using 'GLACCOUNT_SCREEN_CCODE-FSTAG'

t_data-fstag.

if t_data-xintb = 'X'.

Perform bdc_field using 'BDC_CURSOR'

'GLACCOUNT_SCREEN_CCODE-XINTB'.

perform bdc_field using 'GLACCOUNT_SCREEN_CCODE-XINTB'

'X'.

endif.

if t_data-xgkon = 'X'.

perform bdc_field using 'BDC_CURSOR'

'GLACCOUNT_SCREEN_CCODE-XGKON'.

perform bdc_field using 'GLACCOUNT_SCREEN_CCODE-XGKON'

'X'.

endif.

perform bdc_field using 'GLACCOUNT_SCREEN_CCODE-HBKID'

t_data-hbkid.

perform bdc_field using 'GLACCOUNT_SCREEN_CCODE-HKTID'

t_data-hktid.

*Lastly edited by abap01

*perform bdc_dynpro using 'SAPLGL_ACCOUNT_MASTER_MAINTAIN' '2001'.

*perform bdc_field using 'BDC_OKCODE'

*'/EEXIT'.

*perform bdc_field using 'BDC_CURSOR'

*'GLACCOUNT_SCREEN_CCODE-XGKON'.

*perform bdc_dynpro using 'SAPLSPO1' '0100'.

*perform bdc_field using 'BDC_OKCODE'

*'=YES'.

*Lastly edited by abap01

ENDFORM. " fill_bdc_structure

&----


*& Form bdc_transaction

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM bdc_transaction .

bdc_mode = 'A'.

CALL TRANSACTION 'FS00' USING t_bdcdata

MODE bdc_mode

UPDATE 'S'

MESSAGES INTO t_bdcmsg.

*Record error if sales order not changed

LOOP AT t_bdcmsg WHERE msgtyp EQ 'E'

OR msgtyp EQ 'A'.

CLEAR t_invalid_data.

MOVE-CORRESPONDING t_data TO t_invalid_data.

CALL FUNCTION 'FORMAT_MESSAGE'

EXPORTING

id = t_bdcmsg-msgid

lang = 'EN'

no = t_bdcmsg-msgnr

v1 = t_bdcmsg-msgv1

v2 = t_bdcmsg-msgv2

v3 = t_bdcmsg-msgv3

v4 = t_bdcmsg-msgv4

IMPORTING

msg = t_invalid_data-reason

EXCEPTIONS

not_found = 1

OTHERS = 2.

APPEND t_invalid_data.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

ENDLOOP.

ENDFORM. " bdc_transaction

&----


*& Form bdc_dynpro

&----


  • text

----


  • -->P_0749 text

  • -->P_0750 text

----


FORM bdc_dynpro USING program dynpro.

CLEAR t_bdcdata.

t_bdcdata-program = program.

t_bdcdata-dynpro = dynpro.

t_bdcdata-dynbegin = 'X'.

APPEND t_bdcdata.

ENDFORM. " bdc_dynpro

&----


*& Form bdc_field

&----


  • text

----


  • -->P_0779 text

  • -->P_0780 text

----


FORM bdc_field USING fnam fval.

CLEAR t_bdcdata.

t_bdcdata-fnam = fnam.

t_bdcdata-fval = fval.

APPEND t_bdcdata.

ENDFORM. " bdc_field

&----


*& Form write_failed_data

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM write_failed_data .

LOOP AT t_invalid_data.

WRITE :/1 t_invalid_data-saknr,

9 t_invalid_data-bukrs,

14 t_invalid_data-ktoks,

65 t_invalid_data-txt20,

76 t_invalid_data-reason.

ENDLOOP.

ENDFORM. " write_failed_data

Tags:
Former Member

Helpful Answer

by
Not what you were looking for? View more on this topic or Ask a question