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 program

Former Member
0 Likes
964

Hi,

I have a problem with BDC that the records which i enter during recording are displayed in the table & the records which i'm trying to get from the file into the table are not displayed.

Can anyone pls guide me how to proceed ?

Thanks in advance,

Sipra

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
944

Hi,

thanks for your response.

well i'm sending my code as i'm not able to make out where the problem lies.

report ZS_BDCPROGRAM

no standard page heading line-size 255.

include bdcrecx1.

parameters: dataset(132) lower case default

'zs_file'.

      • 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 ***

types: begin of x_ff,

  • data element:

INPUT1_001(010),

  • data element:

INPUT2_002(001),

  • data element:

INPUT1_003(010),

  • data element:

INPUT2_004(001),

  • data element:

INPUT1_005(010),

  • data element:

INPUT1_006(010),

end of x_ff.

      • End generated data section ***

&----


  • DECLARATIONS

&----


  • Flat file

DATA: i_ff TYPE x_ff OCCURS 0 WITH HEADER LINE.

  • BDC Data

DATA: i_bdc LIKE BDCDATA OCCURS 0 WITH HEADER LINE.

start-of-selection.

  • Get Flat file Data

PERFORM GET_DATA.

  • Create BDC Data

PERFORM GENERATE.

FORM GET_DATA .

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

FILENAME = 'C:\zs_file.txt'

FILETYPE = 'ASC'

HAS_FIELD_SEPARATOR = 'X'

  • HEADER_LENGTH = 0

  • READ_BY_LINE = 'X'

  • DAT_MODE = ' '

  • CODEPAGE = ' '

  • IGNORE_CERR = ABAP_TRUE

  • REPLACEMENT = '#'

  • CHECK_BOM = ' '

  • VIRUS_SCAN_PROFILE =

  • IMPORTING

  • FILELENGTH =

  • HEADER =

TABLES

DATA_TAB = i_bdc

EXCEPTIONS

FILE_OPEN_ERROR = 1

FILE_READ_ERROR = 2

NO_BATCH = 3

GUI_REFUSE_FILETRANSFER = 4

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.

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

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

write:'sorry'.

ENDIF.

endform.

FORM GENERATE .

DATA: LV_DATE LIKE SY-DATUM.

LV_DATE = SY-DATUM - 1.

CALL FUNCTION 'BDC_OPEN_GROUP'

EXPORTING

CLIENT = SY-MANDT

  • DEST = FILLER8

GROUP = 'zs_recording'

HOLDDATE = LV_DATE

KEEP = 'X'

USER = sy-uname

  • RECORD = FILLER1

  • PROG = SY-CPROG

  • DCPFM = '%'

  • DATFM = '%'

  • IMPORTING

  • QID =

EXCEPTIONS

CLIENT_INVALID = 1

DESTINATION_INVALID = 2

GROUP_INVALID = 3

GROUP_IS_LOCKED = 4

HOLDDATE_INVALID = 5

INTERNAL_ERROR = 6

QUEUE_ERROR = 7

RUNNING = 8

SYSTEM_LOCK_ERROR = 9

USER_INVALID = 10

OTHERS = 11

.

IF SY-SUBRC <> 0.

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

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

write:'excuse us'.

ENDIF.

if sy-subrc = 0.

loop at i_ff.

perform populate using:'X' 'ZSIPPROGRAM' '0100',

' ' 'BDC_OKCODE' '/ESAVE',

' ' 'BDC_CURSOR' 'INPUT2',

' ' 'INPUT1' i_ff-INPUT1_001,

' ' 'INPUT2' i_ff-INPUT2_002,

'X' 'ZSIPPROGRAM' '0100',

' ' 'BDC_OKCODE' '/ERESET',

' ' 'BDC_CURSOR' 'INPUT1',

' ' 'INPUT1' i_ff-INPUT1_003,

' ' 'INPUT2' i_ff-INPUT2_004,

'X' 'ZSIPPROGRAM' '0100',

' ' 'BDC_OKCODE' '/ESAVE',

' ' 'BDC_CURSOR' 'INPUT1',

'X' 'ZSIPPROGRAM' '0100',

' ' 'BDC_OKCODE' '/ESAVE',

' ' 'BDC_CURSOR' 'INPUT1',

' ' 'INPUT1' i_ff-INPUT1_005,

'X' 'ZSIPPROGRAM' '0100',

' ' 'BDC_CURSOR' 'INPUT1',

' ' 'BDC_OKCODE' '=EXIT',

' ' 'INPUT1' i_ff-INPUT1_006.

CALL FUNCTION 'BDC_INSERT'

EXPORTING

TCODE = 'zsipprogram'

  • POST_LOCAL = NOVBLOCAL

  • PRINTING = NOPRINT

  • SIMUBATCH = ' '

  • CTUPARAMS = ' '

TABLES

DYNPROTAB = i_bdc

EXCEPTIONS

INTERNAL_ERROR = 1

NOT_OPEN = 2

QUEUE_ERROR = 3

TCODE_INVALID = 4

PRINTING_INVALID = 5

POSTING_INVALID = 6

OTHERS = 7

.

IF SY-SUBRC <> 0.

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

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

write:'excuse me'.

ENDIF.

CLEAR: i_bdc[].

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.

endif.

endform.

FORM POPULATE USING VALUE(P_A)

VALUE(P_B)

VALUE(P_C).

IF P_A = 'X'.

i_bdc-PROGRAM = P_B.

i_bdc-DYNPRO = P_C.

i_bdc-DYNBEGIN = 'X'.

ELSE.

i_bdc-FNAM = P_B.

i_bdc-FVAL = P_C.

ENDIF.

APPEND i_bdc.

CLEAR i_bdc.

ENDFORM. " POPULATE

please guide me.

Regards,

Sipra

8 REPLIES 8
Read only

hymavathi_oruganti
Active Contributor
0 Likes
944

probqably , u r mapping statically, i mean u may be hard coding ur mapping with the values of recording.

use variables,

example:

perform bdc_dynpro using 'SAPMM06E' '0120'.

perform bdc_field using 'BDC_CURSOR'

v_bstpo.

perform bdc_field using 'BDC_OKCODE'

'=DETA'.

perform bdc_field using 'RM06E-EBELP'

v_ebelpt.

perform bdc_dynpro using 'SAPMM06E' '0111'.

perform bdc_field using 'BDC_CURSOR'

'EKPO-BSTAE'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_dynpro using 'SAPMM06E' '0120'.

perform bdc_field using 'BDC_CURSOR'

v_bstpo.

perform bdc_field using 'BDC_OKCODE'

'=BSTA'.

perform bdc_field using 'RM06E-EBELP'

v_ebelpt.

perform bdc_field using v_tcselflag

'X'.

Read only

Former Member
0 Likes
944

Hi sipra

check you UPLOAD function.

try debugging whether the internal table is populating or not.

for further help you can post your code(only the upoad function)

regards

kishore

Read only

Former Member
0 Likes
944

HI Sipra,

In case if you are fetching the data in to Internal table from a flat file hope there exists a prob in usage of CALL FUNCTION GUI_UPLOAD if you are trying to fetch the data from the application server then check whether the path is correct and there exists data in that.

also check whether you are popuating the dada to the internal table in this fashion .....

LOOP AT IT_FFCUST.

PERFORM POPULATEBDC USING :

'X' 'SAPMF02D' '0105',

' ' 'BDC_OKCODE' '/00' ,

' ' 'RF02D-KUNNR' IT_FFCUST-KUNNR,

' ' 'RF02D-BUKRS' IT_FFCUST-BUKRS,

' ' 'RF02D-KTOKD' IT_FFCUST-KTOKD,

'X' 'SAPMF02D' '0110' ,

' ' 'BDC_OKCODE' '/00',

' ' 'KNA1-ANRED' IT_FFCUST-ANRED,

' ' 'KNA1-NAME1' IT_FFCUST-NAME1,

' ' 'KNA1-SORTL' IT_FFCUST-SORTL,

' ' 'KNA1-STRAS' IT_FFCUST-STRAS,

' ' 'KNA1-ORT01' IT_FFCUST-ORT01,

' ' 'KNA1-PSTLZ' IT_FFCUST-PSTLZ,

' ' 'KNA1-LAND1' IT_FFCUST-LAND1,

' ' 'KNA1-SPRAS' IT_FFCUST-SPRAS,

'X' 'SAPMFO2D' '0120',

' ' 'BDC_OKCODE' '/00',

'X' 'SAPMF02D' '0125',

' ' 'BDC_OKCODE' '/00',

'X' 'SAPMF02D' '0130',

' ' 'BDC_OKCODE' '=ENTR',

'X' 'SAPMF02D' '0340',

' ' 'BDC_OKCODE' '=ENTR',

'X' 'SAPMF02D' '0360',

' ' 'BDC_OKCODE' '=ENTR',

'X' 'SAPMF02D' '0210',

' ' 'KNB1-AKONT' IT_FFCUST-AKONT,

' ' 'BDC_OKCODE' '/00',

'X' 'SAPMF02D' '0215',

' ' 'BDC_OKCODE' '/00',

'X' 'SAPMF02D' '0220',

' ' 'BDC_OKCODE' '/00',

'X' 'SAPMF02D' '0230',

' ' 'BDC_OKCODE' '=UPDA'.

ENDLOOP

Regards,

Santosh

Read only

Former Member
0 Likes
945

Hi,

thanks for your response.

well i'm sending my code as i'm not able to make out where the problem lies.

report ZS_BDCPROGRAM

no standard page heading line-size 255.

include bdcrecx1.

parameters: dataset(132) lower case default

'zs_file'.

      • 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 ***

types: begin of x_ff,

  • data element:

INPUT1_001(010),

  • data element:

INPUT2_002(001),

  • data element:

INPUT1_003(010),

  • data element:

INPUT2_004(001),

  • data element:

INPUT1_005(010),

  • data element:

INPUT1_006(010),

end of x_ff.

      • End generated data section ***

&----


  • DECLARATIONS

&----


  • Flat file

DATA: i_ff TYPE x_ff OCCURS 0 WITH HEADER LINE.

  • BDC Data

DATA: i_bdc LIKE BDCDATA OCCURS 0 WITH HEADER LINE.

start-of-selection.

  • Get Flat file Data

PERFORM GET_DATA.

  • Create BDC Data

PERFORM GENERATE.

FORM GET_DATA .

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

FILENAME = 'C:\zs_file.txt'

FILETYPE = 'ASC'

HAS_FIELD_SEPARATOR = 'X'

  • HEADER_LENGTH = 0

  • READ_BY_LINE = 'X'

  • DAT_MODE = ' '

  • CODEPAGE = ' '

  • IGNORE_CERR = ABAP_TRUE

  • REPLACEMENT = '#'

  • CHECK_BOM = ' '

  • VIRUS_SCAN_PROFILE =

  • IMPORTING

  • FILELENGTH =

  • HEADER =

TABLES

DATA_TAB = i_bdc

EXCEPTIONS

FILE_OPEN_ERROR = 1

FILE_READ_ERROR = 2

NO_BATCH = 3

GUI_REFUSE_FILETRANSFER = 4

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.

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

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

write:'sorry'.

ENDIF.

endform.

FORM GENERATE .

DATA: LV_DATE LIKE SY-DATUM.

LV_DATE = SY-DATUM - 1.

CALL FUNCTION 'BDC_OPEN_GROUP'

EXPORTING

CLIENT = SY-MANDT

  • DEST = FILLER8

GROUP = 'zs_recording'

HOLDDATE = LV_DATE

KEEP = 'X'

USER = sy-uname

  • RECORD = FILLER1

  • PROG = SY-CPROG

  • DCPFM = '%'

  • DATFM = '%'

  • IMPORTING

  • QID =

EXCEPTIONS

CLIENT_INVALID = 1

DESTINATION_INVALID = 2

GROUP_INVALID = 3

GROUP_IS_LOCKED = 4

HOLDDATE_INVALID = 5

INTERNAL_ERROR = 6

QUEUE_ERROR = 7

RUNNING = 8

SYSTEM_LOCK_ERROR = 9

USER_INVALID = 10

OTHERS = 11

.

IF SY-SUBRC <> 0.

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

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

write:'excuse us'.

ENDIF.

if sy-subrc = 0.

loop at i_ff.

perform populate using:'X' 'ZSIPPROGRAM' '0100',

' ' 'BDC_OKCODE' '/ESAVE',

' ' 'BDC_CURSOR' 'INPUT2',

' ' 'INPUT1' i_ff-INPUT1_001,

' ' 'INPUT2' i_ff-INPUT2_002,

'X' 'ZSIPPROGRAM' '0100',

' ' 'BDC_OKCODE' '/ERESET',

' ' 'BDC_CURSOR' 'INPUT1',

' ' 'INPUT1' i_ff-INPUT1_003,

' ' 'INPUT2' i_ff-INPUT2_004,

'X' 'ZSIPPROGRAM' '0100',

' ' 'BDC_OKCODE' '/ESAVE',

' ' 'BDC_CURSOR' 'INPUT1',

'X' 'ZSIPPROGRAM' '0100',

' ' 'BDC_OKCODE' '/ESAVE',

' ' 'BDC_CURSOR' 'INPUT1',

' ' 'INPUT1' i_ff-INPUT1_005,

'X' 'ZSIPPROGRAM' '0100',

' ' 'BDC_CURSOR' 'INPUT1',

' ' 'BDC_OKCODE' '=EXIT',

' ' 'INPUT1' i_ff-INPUT1_006.

CALL FUNCTION 'BDC_INSERT'

EXPORTING

TCODE = 'zsipprogram'

  • POST_LOCAL = NOVBLOCAL

  • PRINTING = NOPRINT

  • SIMUBATCH = ' '

  • CTUPARAMS = ' '

TABLES

DYNPROTAB = i_bdc

EXCEPTIONS

INTERNAL_ERROR = 1

NOT_OPEN = 2

QUEUE_ERROR = 3

TCODE_INVALID = 4

PRINTING_INVALID = 5

POSTING_INVALID = 6

OTHERS = 7

.

IF SY-SUBRC <> 0.

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

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

write:'excuse me'.

ENDIF.

CLEAR: i_bdc[].

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.

endif.

endform.

FORM POPULATE USING VALUE(P_A)

VALUE(P_B)

VALUE(P_C).

IF P_A = 'X'.

i_bdc-PROGRAM = P_B.

i_bdc-DYNPRO = P_C.

i_bdc-DYNBEGIN = 'X'.

ELSE.

i_bdc-FNAM = P_B.

i_bdc-FVAL = P_C.

ENDIF.

APPEND i_bdc.

CLEAR i_bdc.

ENDFORM. " POPULATE

please guide me.

Regards,

Sipra

Read only

0 Likes
944

HI

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

FILENAME = 'C:\zs_file.txt'

FILETYPE = 'ASC'

HAS_FIELD_SEPARATOR = 'X'

  • HEADER_LENGTH = 0

  • READ_BY_LINE = 'X'

  • DAT_MODE = ' '

  • CODEPAGE = ' '

  • IGNORE_CERR = ABAP_TRUE

  • REPLACEMENT = '#'

  • CHECK_BOM = ' '

  • VIRUS_SCAN_PROFILE =

  • IMPORTING

  • FILELENGTH =

  • HEADER =

TABLES

<b>DATA_TAB = i_ff</b>

EXCEPTIONS

FILE_OPEN_ERROR = 1

FILE_READ_ERROR = 2

NO_BATCH = 3

GUI_REFUSE_FILETRANSFER = 4

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

regards

kishore

Read only

0 Likes
944

from ur coding, i wonder u r not mapping to any database fields???

' 'INPUT1' i_ff-INPUT1_003,

' ' 'INPUT2' i_ff-INPUT2_004,

what r these INPUT1 AND INPUT2????

Read only

0 Likes
944

Hi Harikishore,

this has not resolved the problem.

the same prob persists.please tell me some solution.

Read only

0 Likes
944

Hi sipra

have changed the tables in the GUI_UPLOAD. it should be <b>i_ff</b>

which i mentioned in the previous reply.

if the problem persists have you debugged the code and checked whether the internal table is populated.

regards

kishore