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 for uploading data into ztable

Former Member
0 Likes
634

Hi,

I have a ztable,which requires 900 records to be uploaded.Can anyone please guide me with the steps for this BDC.I am getting confused.

Thanks.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
502

Hi,

1.First upload the records from flat file to Internal table.

2.Then INSERT/MODIFY the records into the Ztable.

Check:

REPORT zmat_no message-id zebg.

TYPE-POOLS truxs.

TABLES:zmatnr.

DATA : itab LIKE alsmex_tabline OCCURS 0 WITH HEADER LINE.

DATA row LIKE alsmex_tabline-row.

data : g_matnr like mara-matnr.

data : count type i.

data : itab_count type i.

data : gi_final like zmatnr occurs 0 with header line.

*data : begin of gi_final occurs 0,

mat_old like mara-matnr,

mat_new like mara-matnr,

end of gi_final.

***********************Selection Screen*************************

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

PARAMETER : pfname LIKE rlgrap-filename OBLIGATORY.

select-options : records for count.

SELECTION-SCREEN END OF BLOCK b1.

*******************************************************************

*********************At Selection Screen*************************

AT SELECTION-SCREEN ON VALUE-REQUEST FOR pfname.

PERFORM search.

*******************************************************************

START-OF-SELECTION.

perform process.

form process.

CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'

EXPORTING

filename = pfname

i_begin_col = 1

i_begin_row = 2

i_end_col = 12

i_end_row = 65000

TABLES

intern = itab

EXCEPTIONS

inconsistent_parameters = 1

upload_ole = 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.

describe table itab lines itab_count.

row = 1.

loop at itab.

if itab-row row.

append gi_final.

clear gi_final.

endif.

case itab-col.

when '1'.

CLEAR G_MATNR.

gi_final-OLD_MATNR = itab-value.

CONCATENATE 'NEW' gi_final-old_matnr INTO itab-value.

gi_final-new_MATNR = itab-value.

endcase.

row = itab-row.

append gi_final.

clear gi_final.

endloop.

CALL FUNCTION 'PROGRESS_INDICATOR'

EXPORTING

I_TEXT = 'File Has Been Successfully Uploaded from Workstation ' .

if not gi_final[] is initial.

if not records-low is initial .

if not records-high is initial.

records-high = records-high + 1.

DESCRIBE TABLE gi_final LINES count.

IF records-high < count.

DELETE gi_final FROM records-high TO count.

ENDIF.

IF records-low <> 1.

IF records-low 0.

DELETE gi_final FROM 1 TO records-low.

ENDIF.

ENDIF.

endif.

endif.

endif.

IF NOT GI_FINAL[] IS INITIAL.

CALL FUNCTION 'PROGRESS_INDICATOR'

EXPORTING

I_TEXT = 'Processing zmatnr table'

I_OUTPUT_IMMEDIATELY = 'X'.

if itab_count count.

*

message i000 with 'records are not matching'.

*

exit.

*

else.

modify zmatnr from table gi_final.

message i000 with 'data base table modified successfully'.

endif.

endif.

endform.

&----


*& Form search

&----


text

-


--> p1 text

<-- p2 text

-


FORM search .

CALL FUNCTION 'KD_GET_FILENAME_ON_F4'

EXPORTING

static = 'X'

CHANGING

file_name = pfname.

ENDFORM. " search

Regards,

Shiva.

2 REPLIES 2
Read only

Former Member
0 Likes
503

Hi,

1.First upload the records from flat file to Internal table.

2.Then INSERT/MODIFY the records into the Ztable.

Check:

REPORT zmat_no message-id zebg.

TYPE-POOLS truxs.

TABLES:zmatnr.

DATA : itab LIKE alsmex_tabline OCCURS 0 WITH HEADER LINE.

DATA row LIKE alsmex_tabline-row.

data : g_matnr like mara-matnr.

data : count type i.

data : itab_count type i.

data : gi_final like zmatnr occurs 0 with header line.

*data : begin of gi_final occurs 0,

mat_old like mara-matnr,

mat_new like mara-matnr,

end of gi_final.

***********************Selection Screen*************************

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

PARAMETER : pfname LIKE rlgrap-filename OBLIGATORY.

select-options : records for count.

SELECTION-SCREEN END OF BLOCK b1.

*******************************************************************

*********************At Selection Screen*************************

AT SELECTION-SCREEN ON VALUE-REQUEST FOR pfname.

PERFORM search.

*******************************************************************

START-OF-SELECTION.

perform process.

form process.

CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'

EXPORTING

filename = pfname

i_begin_col = 1

i_begin_row = 2

i_end_col = 12

i_end_row = 65000

TABLES

intern = itab

EXCEPTIONS

inconsistent_parameters = 1

upload_ole = 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.

describe table itab lines itab_count.

row = 1.

loop at itab.

if itab-row row.

append gi_final.

clear gi_final.

endif.

case itab-col.

when '1'.

CLEAR G_MATNR.

gi_final-OLD_MATNR = itab-value.

CONCATENATE 'NEW' gi_final-old_matnr INTO itab-value.

gi_final-new_MATNR = itab-value.

endcase.

row = itab-row.

append gi_final.

clear gi_final.

endloop.

CALL FUNCTION 'PROGRESS_INDICATOR'

EXPORTING

I_TEXT = 'File Has Been Successfully Uploaded from Workstation ' .

if not gi_final[] is initial.

if not records-low is initial .

if not records-high is initial.

records-high = records-high + 1.

DESCRIBE TABLE gi_final LINES count.

IF records-high < count.

DELETE gi_final FROM records-high TO count.

ENDIF.

IF records-low <> 1.

IF records-low 0.

DELETE gi_final FROM 1 TO records-low.

ENDIF.

ENDIF.

endif.

endif.

endif.

IF NOT GI_FINAL[] IS INITIAL.

CALL FUNCTION 'PROGRESS_INDICATOR'

EXPORTING

I_TEXT = 'Processing zmatnr table'

I_OUTPUT_IMMEDIATELY = 'X'.

if itab_count count.

*

message i000 with 'records are not matching'.

*

exit.

*

else.

modify zmatnr from table gi_final.

message i000 with 'data base table modified successfully'.

endif.

endif.

endform.

&----


*& Form search

&----


text

-


--> p1 text

<-- p2 text

-


FORM search .

CALL FUNCTION 'KD_GET_FILENAME_ON_F4'

EXPORTING

static = 'X'

CHANGING

file_name = pfname.

ENDFORM. " search

Regards,

Shiva.

Read only

0 Likes
502

Thanks for your help,I have finally uploaded data in Ztable.