Skip to Content

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

bdc error

hi friends,

i have one upload bdc pgm

plz can someone analyze this code n tell wat else should be added plz give me the code if anything to be added

**************----


*********

REPORT zetest2

NO STANDARD PAGE HEADING LINE-SIZE 255.

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

PARAMETERS: r_create RADIOBUTTON GROUP opt1 DEFAULT 'X',

r_change RADIOBUTTON GROUP opt1.

SELECTION-SCREEN END OF BLOCK fl1.

DATA : file_name TYPE string.

PARAMETERS : p_file LIKE rlgrap-filename OBLIGATORY.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.

CLEAR p_file.

CALL FUNCTION 'F4_FILENAME'

    • EXPORTING

    • PROGRAM_NAME = SYST-CPROG

    • DYNPRO_NUMBER = SYST-DYNNR

    • FIELD_NAME = ' '

IMPORTING

file_name = p_file.

*& Data structures -


DATA: BEGIN OF file_int OCCURS 0, "Input file

datsl LIKE rm63e-datsl,

eqtyp LIKE rm63e-eqtyp,

begru LIKE itob-begru,

brgew LIKE itob-brgew,

groes LIKE itob-groes,

invnr LIKE itob-invnr,

inbdt LIKE itob-inbdt,

eqart LIKE itob-eqart,

swerk LIKE itob-swerk,

shtxt LIKE itob-shtxt,

klart LIKE rmclf-klart,

class LIKE rmclf-class,

tidnr LIKE itob-tidnr,

iwerk LIKE itob-iwerk,

herst LIKE itob-herst,

herld LIKE itob-herld,

typbz LIKE itob-typbz,

baujj LIKE itob-baujj,

baumm LIKE itob-baumm,

END OF file_int.

DATA: BEGIN OF bdcdata OCCURS 0. "batch session

INCLUDE STRUCTURE bdcdata.

DATA: END OF bdcdata.

*& data variables -


DATA: bname LIKE apqi-groupid VALUE 'FS_FUNC_LOC'.

*& initialization -


INITIALIZATION.

*& Selection Screen -


AT SELECTION-SCREEN.

*&

*& Main -


START-OF-SELECTION.

PERFORM read_dataset_pc.

END-OF-SELECTION.

PERFORM create_batch_session.

*& Page Events

TOP-OF-PAGE.

END-OF-PAGE.

  • Forms ----------------------------------------------------------------

&----


*& Form CREATE_BATCH_SESSION

&----


FORM create_batch_session.

PERFORM open_batch_session USING bname.

LOOP AT file_int.

PERFORM fill_bdc.

  • IF r_create = 'X'.

PERFORM insert_batch_session USING 'IE01'. "Create

  • ELSE.

  • PERFORM insert_batch_session USING 'IE02'. "Change

  • ENDIF.

ENDLOOP.

PERFORM close_batch_session.

PERFORM start_batch_session USING bname.

ENDFORM. " CREATE_BATCH_SESSION

&----


*& Form OPEN_BATCH_SESSION

&----


FORM open_batch_session USING group.

CALL FUNCTION 'BDC_OPEN_GROUP'

EXPORTING

group = group

user = sy-uname

EXCEPTIONS

client_invalid = 01

destination_invalid = 02

group_invalid = 03

holddate_invalid = 04

internal_error = 05

queue_error = 06

running = 07

user_invalid = 08.

IF sy-subrc NE 0.

MESSAGE e025 WITH 'Unable to open batch input session.'.

ENDIF.

ENDFORM. " OPEN_BATCH_SESSION

&----


*& Form FILL_BDC

&----


FORM fill_bdc.

CLEAR bdcdata.

REFRESH bdcdata.

PERFORM bdc_dynpro USING 'SAPMIEQ0' '0100'.

PERFORM bdc_field USING 'BDC_CURSOR'

'RM63E-EQTYP'.

PERFORM bdc_field USING 'BDC_OKCODE'

'/00'.

PERFORM bdc_field USING 'RM63E-DATSL'

file_int-datsl.

PERFORM bdc_field USING 'RM63E-EQTYP'

file_int-eqtyp.

PERFORM bdc_dynpro USING 'SAPMIEQ0' '0101'.

PERFORM bdc_field USING 'BDC_OKCODE'

'=KL'.

PERFORM bdc_field USING 'ITOB-BEGRU'

file_int-begru.

PERFORM bdc_field USING 'ITOB-BRGEW'

file_int-brgew.

PERFORM bdc_field USING 'ITOB-GROES'

file_int-groes.

PERFORM bdc_field USING 'ITOB-INVNR'

file_int-invnr.

PERFORM bdc_field USING 'ITOB-INBDT'

file_int-inbdt.

PERFORM bdc_field USING 'ITOB-EQART'

file_int-eqart.

PERFORM bdc_field USING 'BDC_CURSOR'

'ITOB-SWERK'.

PERFORM bdc_field USING 'ITOB-SWERK'

file_int-swerk.

PERFORM bdc_field USING 'BDC_CURSOR'

'ITOB-SHTXT'.

PERFORM bdc_field USING 'ITOB-SHTXT'

file_int-shtxt.

PERFORM bdc_dynpro USING 'SAPLCLCA' '0602'.

PERFORM bdc_field USING 'BDC_CURSOR'

'RMCLF-KLART'.

PERFORM bdc_field USING 'BDC_OKCODE'

'=ENTE'.

PERFORM bdc_field USING 'RMCLF-KLART'

file_int-klart.

PERFORM bdc_dynpro USING 'SAPLCLFM' '0500'.

PERFORM bdc_field USING 'BDC_CURSOR'

'RMCLF-CLASS(01)'.

PERFORM bdc_field USING 'BDC_OKCODE'

'/00'.

PERFORM bdc_field USING 'RMCLF-CLASS(01)'

file_int-class.

PERFORM bdc_dynpro USING 'SAPLCTMS' '0109'.

PERFORM bdc_field USING 'BDC_OKCODE'

'/EEOT'.

PERFORM bdc_field USING 'BDC_CURSOR'

'RCTMS-MNAME(01)'.

PERFORM bdc_dynpro USING 'SAPLCLFM' '0500'.

PERFORM bdc_field USING 'BDC_CURSOR'

'RMCLF-CLASS(01)'.

PERFORM bdc_field USING 'BDC_OKCODE'

'=NEUZ'.

PERFORM bdc_dynpro USING 'SAPLCLFM' '0500'.

PERFORM bdc_field USING 'BDC_CURSOR'

'RMCLF-CLASS(02)'.

PERFORM bdc_field USING 'BDC_OKCODE'

'/00'.

PERFORM bdc_field USING 'RMCLF-CLASS(02)'

'LV_EHS_PRESS'.

PERFORM bdc_dynpro USING 'SAPLCTMS' '0109'.

PERFORM bdc_field USING 'BDC_OKCODE'

'/EEOT'.

PERFORM bdc_field USING 'BDC_CURSOR'

'RCTMS-MNAME(01)'.

PERFORM bdc_dynpro USING 'SAPLCLFM' '0500'.

PERFORM bdc_field USING 'BDC_CURSOR'

'RMCLF-CLASS(01)'.

PERFORM bdc_field USING 'BDC_OKCODE'

'=NEUZ'.

PERFORM bdc_dynpro USING 'SAPLCLFM' '0500'.

PERFORM bdc_field USING 'BDC_CURSOR'

'RMCLF-CLASS(02)'.

PERFORM bdc_field USING 'BDC_OKCODE'

'/00'.

PERFORM bdc_field USING 'RMCLF-CLASS(02)'

'LV_BA'.

PERFORM bdc_dynpro USING 'SAPLCTMS' '0109'.

PERFORM bdc_field USING 'BDC_CURSOR'

'RCTMS-MNAME(01)'.

PERFORM bdc_field USING 'BDC_OKCODE'

'/00'.

PERFORM bdc_dynpro USING 'SAPLCTMS' '0109'.

PERFORM bdc_field USING 'BDC_OKCODE'

'/EEOT'.

PERFORM bdc_field USING 'BDC_CURSOR'

'RCTMS-MNAME(01)'.

PERFORM bdc_dynpro USING 'SAPLCLFM' '0500'.

PERFORM bdc_field USING 'BDC_CURSOR'

'RMCLF-CLASS(01)'.

PERFORM bdc_field USING 'BDC_OKCODE'

'=ENDE'.

PERFORM bdc_dynpro USING 'SAPMIEQ0' '0101'.

PERFORM bdc_field USING 'BDC_OKCODE'

'=T\02'.

PERFORM bdc_field USING 'BDC_CURSOR'

'ITOB-SHTXT'.

PERFORM bdc_dynpro USING 'SAPMIEQ0' '0101'.

PERFORM bdc_field USING 'BDC_OKCODE'

'=T\03'.

PERFORM bdc_field USING 'BDC_CURSOR'

'ITOB-SHTXT'.

PERFORM bdc_dynpro USING 'SAPMIEQ0' '0101'.

PERFORM bdc_field USING 'BDC_OKCODE'

'=T\04'.

PERFORM bdc_field USING 'BDC_CURSOR'

'ITOB-TIDNR'.

PERFORM bdc_field USING 'ITOB-TIDNR'

file_int-tidnr.

PERFORM bdc_dynpro USING 'SAPMIEQ0' '0101'.

PERFORM bdc_field USING 'BDC_OKCODE'

'=T\05'.

PERFORM bdc_field USING 'BDC_CURSOR'

'ITOB-IWERK'.

PERFORM bdc_field USING 'ITOB-IWERK'

file_int-iwerk.

PERFORM bdc_dynpro USING 'SAPMIEQ0' '0101'.

PERFORM bdc_field USING 'BDC_OKCODE'

'=T\06'.

PERFORM bdc_field USING 'BDC_CURSOR'

'ITOB-TYPBZ'.

PERFORM bdc_field USING 'ITOB-HERST'

file_int-herst.

PERFORM bdc_field USING 'ITOB-HERLD'

file_int-herld.

PERFORM bdc_field USING 'ITOB-TYPBZ'

file_int-typbz.

PERFORM bdc_field USING 'ITOB-BAUJJ'

file_int-baujj.

PERFORM bdc_field USING 'ITOB-BAUMM'

file_int-baumm.

PERFORM bdc_dynpro USING 'SAPMIEQ0' '0101'.

PERFORM bdc_field USING 'BDC_OKCODE'

'=BU'.

PERFORM bdc_field USING 'BDC_CURSOR'

'ITOB-SHTXT'.

*perform bdc_transaction using 'IE01'.

*perform close_group.

ENDFORM.

&----


*& Form DYNPRO

&----


FORM dynpro USING dynbegin name value.

CLEAR bdcdata.

IF dynbegin = 'X'.

MOVE: name TO bdcdata-program,

value TO bdcdata-dynpro,

'X' TO bdcdata-dynbegin.

ELSE.

MOVE: name TO bdcdata-fnam,

value TO bdcdata-fval.

ENDIF.

CONDENSE: bdcdata-fnam, bdcdata-fval.

APPEND bdcdata.

ENDFORM. " DYNPRO

&----


*& Form INSERT_BATCH_SESSION

&----


FORM insert_batch_session USING transaction.

CALL FUNCTION 'BDC_INSERT'

EXPORTING

tcode = transaction

TABLES

dynprotab = bdcdata

EXCEPTIONS

internal_error = 01

not_open = 02

queue_error = 03

tcode_invalid = 04.

IF sy-subrc NE 0.

MESSAGE e025 WITH 'Unable to insert batch input session.'.

ENDIF.

ENDFORM. " INSERT_BATCH_SESSION

&----


*& Form CLOSE_BATCH_SESSION

&----


FORM close_batch_session.

CALL FUNCTION 'BDC_CLOSE_GROUP'

EXCEPTIONS

not_open = 01

queue_error = 02.

ENDFORM. " CLOSE_BATCH_SESSION

&----


*& Form START_BATCH_SESSION

&----


FORM start_batch_session USING session_name.

COMMIT WORK.

SUBMIT rsbdcsub USING SELECTION-SET session_name AND RETURN.

ENDFORM. " START_BATCH_SESSION

&----


*& Form READ_DATASET_PC

&----


FORM read_dataset_pc.

CALL FUNCTION 'WS_UPLOAD'

EXPORTING

filename = p_file

filetype = 'ASC'

TABLES

data_tab = file_int

EXCEPTIONS

conversion_error = 01

file_open_error = 02

file_read_error = 03

invalid_table_width = 04

invalid_type = 05

no_batch = 06

unknown_error = 07.

IF sy-subrc NE 0.

MESSAGE e074 WITH sy-subrc p_file.

ENDIF.

ENDFORM. " READ_DATASET_PC

thank's&regards

shiva

Tags:
Former Member
Not what you were looking for? View more on this topic or Ask a question