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

Excel upload Error

Former Member
0 Likes
883

Hi friends,

1) i am uploading 500 to 5000 records from excel to tcode using call tranction

i need to retreive error message which particular record and field is

having error

if there is any Function Module let me know r any logic which will

solve my problem

2)before uploading data from excel i should validate the field

eg.Value must exist in table t370k

eg. only if value exist signs left aligned

where and how should i validate [can i validate before perform bdc_field ]

[plz suggest me with sample code]

regards,

soorya

6 REPLIES 6
Read only

Former Member
0 Likes
824

Hi,

Once you upload the data from the excel into the internal table, you can validate the records of the internal table as to whether they exist in that particular table. Now to display the error message you can make use of FM <b>FORMAT_MESSAGE</b>.

use <b>CALL TRANSACTION MODE</b> as A (fro All) and E (for Error) and put message into an internal table IT_MESSAGES type <b>BDCMSGCOLL</b>.That is done this way:

CALL TRANSACTION '<trans name>' USING ITAB MODE 'A' UPDATE 'S' MESSAGE INTO IT_MESSAGES

. Then loop at it_messages and call the above FM.

Regards,

Aswin

Read only

Former Member
0 Likes
824

HI SOORYA,

1) CALL TRANSACTION 'FK02' USING it_bdcdata MODE 'A' messages into it_messages.

WRITE:/ sy-subrc.

perform format_messages.

FORM format_messages .

DATA: l_msg(100).

LOOP AT it_messages.

CALL FUNCTION 'FORMAT_MESSAGE'

EXPORTING

id = it_messages-msgid

lang = sy-langu

no = it_messages-msgnr

v1 = it_messages-msgv1

v2 = it_messages-msgv2

v3 = it_messages-msgv3

v4 = it_messages-msgv4

IMPORTING

msg = l_msg

EXCEPTIONS

not_found = 1

OTHERS = 2.

WRITE:/ l_msg.

ENDLOOP.

ENDFORM.

hope this helps,

priya.

Read only

Former Member
0 Likes
824

Hi soorya,

1. while using CALL TRANSACTION

there is an extension to it

MESSAGES BDCMSGCOL.

2. When any errors/warnings occurs,

while simulating the transaction,

all such messages (E/W/S) get

accumulated in this internal table.

3. From there u can detect and show messges.

4. eg.Value must exist in table t370k

For this purpose,

first of all,

we need to upload data from excel file to internal table.

5. After that we can LOOP at this internal table

and do all necessary validations like :

Value must exist in table t370k

only if value exist signs left aligned

6. If all is ok, then we can use CALL TRANSACTION.

regards,

amit m.

Read only

Former Member
0 Likes
824

data : it_msg like bdcmsgcoll occurs 0 with header line.

call transaction 'PA30' using it_bdcdata mode 'A'

update 'S'

<b>messages into it_msg.</b>

call function 'FORMAT_MESSAGE'

exporting

id = it_msg-msgid

lang = sy-langu

no = it_msg-msgnr

v1 = it_msg-msgv1

v2 = it_msg-msgv2

v3 = it_msg-msgv3

v4 = it_msg-msgv4

importing

msg = v_msg

exceptions

not_found = 1

others = 2.

Read only

Former Member
0 Likes
824

HI

How you are uploading data from Excel to TCODE.

-


Correct me if i am wrong in understanding the scenario.

Also i am providing the Solution along with:

Scenario: You want to upload data from Excel and post that data in some R/3 Transaction say ME21n(PO Creation).

Solution:

1) Create a Z Program for Function Module, Wherein Use FM GUI_UPLOAD for uploading data from EXCEl to Internal Table.

2)Now Remove the Records from Internal table after applying all validations..using LOOP AT or other Internal Table Operation.

3)Now write BDC code within same Program, which will read data from Internal Table and post it in ME21n

-


Revert back, if some more elaborations is required

Cheers,

VIJAY RAHEJA

Read only

Former Member
0 Likes
824

Hai

check the following COde

report z_bdctest

no standard page heading line-size 255.

include bdcrecx1.

data: begin of it_final occurs 0,

kschl_001(004),

werks_002(004),

lifnr_003(010),

matnr_01_004(018),

kbetr_01_005(016),

mwsk1_01_006(002),

end of it_final.

data: begin of l_intern occurs 0.

include structure alsmex_tabline .

data: end of l_intern.

  • * Selection Screen....................................

selection-screen begin of block b1 with frame title text-001.

parameters: p_file like rlgrap-filename

default '' obligatory. " File Name

selection-screen end of block b1.

  • At Selection Screen Event...........................

at selection-screen on value-request for p_file.

call function 'F4_FILENAME'

exporting

program_name = syst-cprog

dynpro_number = syst-dynnr

field_name = ' '

importing

file_name = p_file.

*start-of-selection.

perform upload_file tables it_final

using p_file.

start-of-selection.

perform open_group.

loop at it_final.

perform bdc_dynpro using 'SAPMV13A' '0100'.

perform bdc_field using 'BDC_CURSOR'

'RV13A-KSCHL'.

perform bdc_field using 'BDC_OKCODE'

'=ANTA'.

perform bdc_field using 'RV13A-KSCHL'

it_final-kschl_001.

perform bdc_dynpro using 'SAPLV14A' '0100'.

perform bdc_field using 'BDC_CURSOR'

'RV130-SELKZ(01)'.

perform bdc_field using 'BDC_OKCODE'

'=WEIT'.

perform bdc_dynpro using 'SAPMV13A' '1363'.

perform bdc_field using 'BDC_CURSOR'

'KONP-KBETR(01)'.

perform bdc_field using 'BDC_OKCODE'

'/00'.

perform bdc_field using 'KOMG-WERKS'

it_final-werks_002.

perform bdc_field using 'KOMG-LIFNR'

it_final-lifnr_003.

perform bdc_field using 'KOMG-MATNR(01)'

it_final-matnr_01_004.

perform bdc_field using 'KONP-KBETR(01)'

it_final-kbetr_01_005.

perform bdc_field using 'KONP-MWSK1(01)'

it_final-mwsk1_01_006.

perform bdc_dynpro using 'SAPMV13A' '1363'.

perform bdc_field using 'BDC_CURSOR'

'KOMG-MATNR(01)'.

perform bdc_field using 'BDC_OKCODE'

'=SICH'.

perform bdc_transaction using 'FV11'.

endloop.

perform close_group.

form upload_file tables p_table

using p_file.

  • Data Declarations.......................................

data : l_index type i.

data : l_start_col type i value '1',

l_start_row type i value '2',

l_end_col type i value '256',

l_end_row type i value '65536'.

  • Field Symbols...........................................

field-symbols : <fs>.

call function 'ALSM_EXCEL_TO_INTERNAL_TABLE'

exporting

filename = p_file

i_begin_col = '1'

i_begin_row = '2'

i_end_col = '100'

i_end_row = '40000'

tables

intern = l_intern

exceptions

inconsistent_parameters = 1

upload_ole = 2

others = 3 .

if sy-subrc ne 0.

format color col_background intensified.

write : / 'File Error'.

exit.

endif.

if l_intern[] is initial.

format color col_background intensified.

write : / 'No Data Uploaded'.

exit.

else.

sort l_intern by row col.

loop at l_intern.

move l_intern-col to l_index.

assign component l_index of structure p_table to <fs>.

move l_intern-value to <fs>.

at end of row.

append p_table.

clear p_table.

endat.

endloop.

endif.

endform.

Thanks & regards

Sreeni