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 for ztable

former_member202957
Contributor
0 Kudos

Hi experts,

I want to know is there any possiblity of writing BDC for inseting values in ZTABLE.? IF yes how using which t-code u ll do that and wht are the nessasity be maintained to write bdc for inseting data in ztable.? is there any example for that? Please tell me.

I know the inseting the values in ztable using report but i want to know by using BDC.

<b>uesful answers will be rewarded</b>.

Regards,

sunil kairam.

9 REPLIES 9

Former Member
0 Kudos

hi,

first upload data from excel into internal table. and use modify command to update datbase table

check this code

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

0 Kudos

hi naresh,

Thankx for your early reply, i know this method of coverting excel to internal table and then iserting into ztable. But i want to know hw it is possible using BDC. I got the requiment to that using BDC only. please help me.

Regards,

sunil kairam.

0 Kudos

Hi

Ok do one thing ,

create a table maintannce for that ZTABLE and record that table maintatnce with SHDB

after recording i think you know how to write the code for BDC based on recording

<b>Rewar dif usefull</b>

0 Kudos

hi naresh,

I have done recording for t-code SM30. But wht happend whe i am executing i can see the fields are getting the values which are in flat file at the end when the ok_code =save the values are initializing. So no record is saving in the ztable. more over it is giving lots of problems i dont konow why I know BDC recording and how to wirte bdc but u have any idea that u hv done inserting BDC using SM30.??? coz i never done eariler before so i am not sure is it possible or not. But after trying i am facing lots of problems. In Table maintence generator i have taken two screen. can this can make a differnce in recording???

<b>thanks & Regards,

sunil kairam.

0 Kudos

Hi Sunil,

Check this link .

Thanks

Mohinder Singh Chauhan

0 Kudos

Hi

While recording just mentioned the tcode as SM30 and then it takes you automaticcaly to that transaction code then enter the table name and press maintain tab and then select new entreis. Enter the values then save it. Press back button. Now it will take return to recording section. now u can able to see the recoding section. Generate the program automaticcaly from the recording. Now take neccessary internal tables and complete the code. Reply for any queries and reward for useful points. Take care while recording. Don't mention any wrong values.

0 Kudos

HI Sunil is it your problem solved

0 Kudos

Hi naresh,

No naresh, i have done the same as u said but the problem i am getting is during the ok_code =save at this time only the primary keys values are saving and the remaing fields values are initilizing. I am not understandig why this problem is coming.

Naresh while we convert recording to program. we find two radio buttons 1.Transfer from recording and another i dont remember which is the best one .I have taken the default internal table it will generate. It will give probelm taking the system defind internal table.? is it effect the BDC progra.

Thanks & Regards,

sunil kumar.

0 Kudos

Hi

there are @ radiobuttons

1)Read from File

2)transfer from recording

yes it will give some problem

do one thing

you will fine one include in that

<b>include bdcrecx1.</b>

create a new program include this line in you program thats all

and write the code based on the screen flow

don't use that program it will be problematic in the feture

<b>Rewar di fusefull</b>