Application Development 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: 

bdc prog correction

Former Member
0 Kudos

Hi

I am writing a bdc prog which will pick up the input text file from presenation server and upload the same into time infotype.

but while running the prog in debug mode the control goes to SAP easy access menu, please suggest where is the fault.

find below the code.

Regards,

report Z_BDCTREC

no standard page heading line-size 255.

*include bdcrecx1.

data: begin of itab occurs 0,

pernr like teven-pernr,

ldate like teven-ldate,

ltime like teven-ltime,

satza like teven-satza,

dallf like teven-dallf,

abwgr like teven-abwgr,

origf like teven-origf,

end of itab.

DATA: BDCDATA LIKE BDCDATA OCCURS 0 WITH HEADER LINE.

&----


&

  • SELECTION-SCREEN *

&----


&

selection-screen begin of block blk1 WITH FRAME TITLE text-002.

*PARAMETERS: infile like rlgrap-filename DEFAULT 'c:\inputfile.txt'.

PARAMETERS: PFILE LIKE RLGRAP-FILENAME DEFAULT ''.

DATA f_name TYPE STRING.

selection-screen end of block blk1.

at selection-screen on value-request for pfile.

call function 'F4_FILENAME'

exporting

program_name = syst-repid

dynpro_number = syst-dynnr

field_name = 'pfile'

importing

file_name = pfile.

start-of-selection.

      • DO NOT CHANGE - the generated data section - DO NOT CHANGE ***

*

  • If it is nessesary to change the data section use the rules:

  • 1.) Each definition of a field exists of two lines

  • 2.) The first line shows exactly the comment

  • '* data element: ' followed with the data element

  • which describes the field.

  • If you don't have a data element use the

  • comment without a data element name

  • 3.) The second line shows the fieldname of the

  • structure, the fieldname must consist of

  • a fieldname and optional the character '_' and

  • three numbers and the field length in brackets

  • 4.) Each field must be type C.

*

      • Generated data section with specific formatting - DO NOT CHANGE ***

data: begin of record,

  • data element: PERNR_D

PERNR_001(038),

  • data element: TIMRE

TIMR6_002(001),

  • data element: BEGST

BEGDA_003(010),

  • data element: CHOIC

CHOIC_004(035),

  • data element: PERNR_D

PERNR_005(038),

  • data element: TIMRE

TIMR6_006(001),

  • data element: BEGST

BEGDA_007(010),

  • data element: CHOIC

CHOIC_008(035),

  • data element: LDATE

LDATE_009(010),

  • data element: LTIME

LTIME_010(008),

  • data element: RETYP

SATZA_011(003),

end of record.

      • End generated data section ***

*start-of-selection.

START-OF-SELECTION.

CALL FUNCTION 'WS_UPLOAD'

EXPORTING

FILENAME = pfile

FILETYPE = 'ASC'

TABLES

DATA_TAB = itab

EXCEPTIONS

CONVERSION_ERROR = 1

FILE_OPEN_ERROR = 2

FILE_READ_ERROR = 3

INVALID_TYPE = 4

NO_BATCH = 5

UNKNOWN_ERROR = 6

INVALID_TABLE_WIDTH = 7

GUI_REFUSE_FILETRANSFER = 8

CUSTOMER_ERROR = 9

OTHERS = 10.

IF SY-SUBRC EQ 0.

write : 'successful'.

else.

write: 'error in input file'.

endif.

*perform open_group.

CALL FUNCTION 'BDC_OPEN_GROUP'

EXPORTING CLIENT = SY-MANDT

GROUP = 'vendor'

USER = sy-uname

KEEP = 'x'

PROG = SY-CPROG .

loop at itab.

perform bdc_dynpro using 'SAPMP50A' '1000'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'RP50G-PERNR'

record-PERNR_001.

perform bdc_field using 'RP50G-TIMR6'

record-TIMR6_002.

perform bdc_field using 'RP50G-BEGDA'

record-BEGDA_003.

perform bdc_field using 'BDC_CURSOR'

'RP50G-CHOIC'.

perform bdc_field using 'RP50G-CHOIC'

record-CHOIC_004.

perform bdc_dynpro using 'SAPMP50A' '1000'.

perform bdc_field using 'BDC_CURSOR'

'RP50G-PERNR'.

perform bdc_field using 'BDC_OKCODE'

'=INS'.

perform bdc_field using 'RP50G-PERNR'

record-PERNR_005.

perform bdc_field using 'RP50G-TIMR6'

record-TIMR6_006.

perform bdc_field using 'RP50G-BEGDA'

record-BEGDA_007.

perform bdc_field using 'RP50G-CHOIC'

record-CHOIC_008.

perform bdc_dynpro using 'MP200000' '2500'.

*These fields will be inserted into time infotype 2011.

perform bdc_field using 'BDC_CURSOR'

'itab-SATZA'.

perform bdc_field using 'BDC_OKCODE'

'=UPD'.

perform bdc_field using 'P2011-LDATE'

itab-LDATE.

perform bdc_field using 'P2011-LTIME'

itab-LTIME.

perform bdc_field using 'P2011-SATZA'

itab-SATZA.

CALL FUNCTION 'BDC_INSERT'

EXPORTING

TCODE = 'PA61'

TABLES

DYNPROTAB = BDCDATA.

refresh bdcdata.

endloop.

CALL FUNCTION 'BDC_CLOSE_GROUP'

  • EXCEPTIONS

  • NOT_OPEN = 1

  • QUEUE_ERROR = 2

  • OTHERS = 3

.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

FORM BDC_DYNPRO USING PROGRAM DYNPRO.

CLEAR BDCDATA.

BDCDATA-PROGRAM = PROGRAM.

BDCDATA-DYNPRO = DYNPRO.

BDCDATA-DYNBEGIN = 'X'.

APPEND BDCDATA.

ENDFORM.

----


  • Insert field *

----


FORM BDC_FIELD USING FNAM FVAL.

CLEAR BDCDATA.

BDCDATA-FNAM = FNAM.

BDCDATA-FVAL = FVAL.

APPEND BDCDATA.

ENDFORM.

1 REPLY 1

rainer_hbenthal
Active Contributor
0 Kudos

As far is i can see you are just reading a file and try to insert those value 1:1. This will not work, depending on the input data you have to convert tha data to what it is expected in the bdc, e.g. date formats may differ, values might be sepearted by comma, but needed to be seperated by a dot.