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 Recording Error

Former Member
0 Likes
626

Hello Experts,

Ive used BDC recording for the transaction ME2L. Here's the recording..

<u><b>Recording</b></u>

perform bdc_dynpro using 'RM06EL00' '1000'.

perform bdc_field using 'BDC_CURSOR'

'S_MATNR-LOW'.

perform bdc_field using 'BDC_OKCODE'

'=ONLI'.

perform bdc_field using 'EL_LIFNR-LOW'

it_matmaster-lifnr.

perform bdc_field using 'LISTU'

'ALV'.

perform bdc_field using 'S_WERKS-LOW'

it_matmaster-werks.

perform bdc_field using 'S_MATNR-LOW'

it_matmaster-matnr.

perform bdc_dynpro using 'SAPLSLVC_FULLSCREEN' '0500'.

<u><b>perform bdc_field using 'BDC_OKCODE'

'=%PC'.</b></u>

perform bdc_dynpro using 'SAPLSPO5' '0101'.

perform bdc_field using 'BDC_CURSOR'

'SPOPLI-SELFLAG(02)'.

perform bdc_field using 'BDC_OKCODE'

'=OK'.

perform bdc_field using 'SPOPLI-SELFLAG(01)'

' '.

perform bdc_field using 'SPOPLI-SELFLAG(02)'

'X'.

perform bdc_dynpro using 'SAPLSFES' '0200'.

perform bdc_field using 'BDC_CURSOR'

'DY_PATH'.

perform bdc_field using 'BDC_OKCODE'

'=FILE'.

perform bdc_field using 'DY_PATH'

'C:\Documents and Settings\satish.jadhav\Desktop\'.

perform bdc_field using 'DY_FILENAME'

'BDC_ME2l.xls'.

perform bdc_dynpro using 'SAPLSLVC_FULLSCREEN' '0500'.

perform bdc_field using 'BDC_OKCODE'

'=&F03'.

perform bdc_transaction using 'ME2L'.

The highlighted part is to download the report to Local xls file. But once it comes to that command it says <b>Function Code cant be selected.</b>

But if i select it manually in the while running the BDC it goes on properly on the next steps. I dont understand what the error is?

Please help!!!!!!!!

Regards,

<b>Prashant Kamat</b>

3 REPLIES 3
Read only

Former Member
0 Likes
499

this is the entire code..

report ZME2L_BDC

no standard page heading line-size 255.

include bdcrecx1.

parameters: dataset(132) lower case.

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

*

DATA: begin of it_matmaster occurs 0,

lifnr type lifnr,

werks type werks,

matnr type matnr,

end of it_matmaster.

DATA:v_file TYPE string.

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

data: begin of record,

  • data element:

LOW_001(010),

  • data element:

LISTU_002(010),

  • data element:

LOW_003(004),

  • data element:

LOW_004(018),

  • data element: OAX

SELFLAG_01_005(001),

  • data element: OAX

SELFLAG_02_006(001),

  • data element:

DY_PATH_007(255),

  • data element:

DY_FILENAME_008(255),

end of record.

PARAMETERS:p_file LIKE rlgrap-filename OBLIGATORY.

      • End generated data section ***

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.

CALL FUNCTION 'F4_FILENAME'

EXPORTING

program_name = syst-cprog

dynpro_number = syst-dynnr

field_name = 'P_FILE'

IMPORTING

file_name = p_file.

start-of-selection.

v_file = p_file.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

filename = v_file

filetype = 'ASC'

has_field_separator = 'X'

  • HEADER_LENGTH = 0

  • READ_BY_LINE = 'X'

  • DAT_MODE = ' '

  • IMPORTING

  • FILELENGTH =

  • HEADER =

TABLES

data_tab = it_matmaster

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.

ENDIF.

*perform open_dataset using dataset.

*perform open_group.

loop at it_matmaster.

perform bdc_dynpro using 'RM06EL00' '1000'.

perform bdc_field using 'BDC_CURSOR'

'S_MATNR-LOW'.

perform bdc_field using 'BDC_OKCODE'

'=ONLI'.

perform bdc_field using 'EL_LIFNR-LOW'

it_matmaster-lifnr.

perform bdc_field using 'LISTU'

'ALV'.

perform bdc_field using 'S_WERKS-LOW'

it_matmaster-werks.

perform bdc_field using 'S_MATNR-LOW'

it_matmaster-matnr.

perform bdc_dynpro using 'SAPLSLVC_FULLSCREEN' '0500'.

<b>perform bdc_field using 'BDC_OKCODE' '=%PC'.</b>

perform bdc_dynpro using 'SAPLSPO5' '0101'.

perform bdc_field using 'BDC_CURSOR'

'SPOPLI-SELFLAG(02)'.

perform bdc_field using 'BDC_OKCODE'

'=OK'.

perform bdc_field using 'SPOPLI-SELFLAG(01)'

' '.

perform bdc_field using 'SPOPLI-SELFLAG(02)'

'X'.

perform bdc_dynpro using 'SAPLSFES' '0200'.

perform bdc_field using 'BDC_CURSOR'

'DY_PATH'.

perform bdc_field using 'BDC_OKCODE'

'=FILE'.

perform bdc_field using 'DY_PATH'

'C:\Documents and Settings\satish.jadhav\Desktop\'.

perform bdc_field using 'DY_FILENAME'

'BDC_ME2l.xls'.

perform bdc_dynpro using 'SAPLSLVC_FULLSCREEN' '0500'.

perform bdc_field using 'BDC_OKCODE' '=&F03'.

perform bdc_transaction using 'ME2L'.

endloop.

*perform close_group.

*perform close_dataset using dataset.

%pc is the function code of the button that is used to download to local file in spreadsheet format where im getting the error..

Please Help

Prashant

Read only

Former Member
0 Likes
499

Experts,

Please go through the problem and suggest me some solution..

Regards,

Prashant Kamat

Read only

0 Likes
499

BDC will not work since it is report program and use submit command..

SUBMIT report name VIA SELECTION-SCREEN

WITH SELECTION-TABLE t_param

AND RETURN.