‎2007 Apr 06 8:12 AM
Hi,
I wanted to "update" my userdefined table using ZFM using function module. could any one give sample code on this.
I have created a table ZT1 of fields (f1,f2,f3).
Regards
Gopi
Message was edited by:
Gopi Tiyyam
‎2007 Apr 06 3:58 PM
Hi,
You do not need function module to do this. It is just one INSERT statement. Check this code. This code is to insert new line into table ZT1.
If you have defined any key field in this table, and you want to modify / add record in this table then this code chage little bit. In that case, firt you have to check if the entry exist in table ZT1 with same key field. If entry exist then you do <b>UPDATE</b> otherwise you do<b> INSERT</b>.
*----------------------------------------------------------------------*
*----------------------------------------------------------------------*
DATA: lit_zt1 LIKE STANDARD TABLE OF zt1 WITH HEADER LINE.
lit_zt1-f1 = 'A'.
lit_zt1-f1 = 'B'.
lit_zt1-f1 = 'C'.
APPEND lit_zt1.
lit_zt1-f1 = 'D'.
lit_zt1-f1 = 'E'.
lit_zt1-f1 = 'F'.
APPEND lit_zt1.
lit_zt1-f1 = '1'.
lit_zt1-f1 = '2'.
lit_zt1-f1 = '3'.
APPEND lit_zt1.
lit_zt1-f1 = '4'.
lit_zt1-f1 = '5'.
lit_zt1-f1 = '6'.
APPEND lit_zt1.
INSERT zt1 FROM TABLE lit_zt1.
*----------------------------------------------------------------------*
*----------------------------------------------------------------------*Let me know if you have any question.
Regards,
RS
‎2007 Apr 06 8:15 AM
Hi Gopi
See the below links for the complete information about BAPI:
The foll. links gives you step by step eg for learning bapi.
http://www.erpgenie.com/sap/abap/bapi/example.htm
http://www.sap-img.com/bapi.htm
http://help.sap.com/saphelp_nw04/helpdata/en/e0/9eb2370f9cbe68e10000009b38f8cf/frameset.htm
http://help.sap.com/saphelp_nw04/helpdata/en/43/b46c1e53c111d395fa00a0c94260a5/content.htm
http://www.sappoint.com/abap/bapiintro.pdf#search=%22BAPI(SAP)%22
http://www.erpgenie.com/sap/abap/bapi/index.htm
http://www.erpgenie.com/sap/abap/bapi/conventions.htm
http://www.erpgenie.com/sapgenie/docs/BAPI%20Programming.doc
Thanks
‎2007 Apr 06 8:16 AM
Use the <b>INSERT <db table> FROM <int table></b> form of insert.
One thing to note here, the number of characters of the db table you created should be 4 or more not less than 4.
Naveen.
‎2007 Apr 06 3:58 PM
Hi,
You do not need function module to do this. It is just one INSERT statement. Check this code. This code is to insert new line into table ZT1.
If you have defined any key field in this table, and you want to modify / add record in this table then this code chage little bit. In that case, firt you have to check if the entry exist in table ZT1 with same key field. If entry exist then you do <b>UPDATE</b> otherwise you do<b> INSERT</b>.
*----------------------------------------------------------------------*
*----------------------------------------------------------------------*
DATA: lit_zt1 LIKE STANDARD TABLE OF zt1 WITH HEADER LINE.
lit_zt1-f1 = 'A'.
lit_zt1-f1 = 'B'.
lit_zt1-f1 = 'C'.
APPEND lit_zt1.
lit_zt1-f1 = 'D'.
lit_zt1-f1 = 'E'.
lit_zt1-f1 = 'F'.
APPEND lit_zt1.
lit_zt1-f1 = '1'.
lit_zt1-f1 = '2'.
lit_zt1-f1 = '3'.
APPEND lit_zt1.
lit_zt1-f1 = '4'.
lit_zt1-f1 = '5'.
lit_zt1-f1 = '6'.
APPEND lit_zt1.
INSERT zt1 FROM TABLE lit_zt1.
*----------------------------------------------------------------------*
*----------------------------------------------------------------------*Let me know if you have any question.
Regards,
RS
‎2007 Apr 09 5:32 AM
Hi,
I have a function mudule like.
FUNCTION Ztable_update.
*"----
*" IMPORTING
*" VALUE(Zf1) LIKE Ztable-Zfield1
*" VALUE(Zf2) LIKE Ztable-Zfiled2 OPTIONAL
*" VALUE(Zf3) LIKE Ztable-Zfield3 OPTIONAL
*"----
//
<b>here i need to write code for table update </b>
ENDFUNCTION.
I WANTED TO UPDATE DATA USING FUNCTION MODULE.
Regards
Gopi
Message was edited by:
Gopi Tiyyam
‎2007 Apr 09 5:46 AM
hI Gopi,
in your ABAP editor where you write actual code,
1.on toolbar--->Pattern. CLick on "Pattern" push button.
2. you will get dialog box asking CALL FUNCTION.
3. write your FM "Ztable_update" and press ENter.
4.your FM will be displayed on Editor asking the fields to be exported.
<b>CALL FUNCTION Ztable_update</b>EXPORTING
Zf1 = Ztable-Zfield1
Zf2 = Ztable-Zfiled2 OPTIONAL
Zf3= Ztable-Zfield3 OPTIONAL
IMPORTING
F1 =
F2 =
.
In FM "Ztable_update"...
write code with the values to be inserted..like:
<b>data: wa like Ztable.
wa-Zf1 = 'val1'.
wa-Zf2 = 'val2'.
wa-Zf3 = 'val3'.
insert Ztable_update from wa.</b>
‎2007 Apr 09 5:50 AM
FUNCTION Ztable_update.
*"----
*" IMPORTING
*" VALUE(Zf1) LIKE Ztable-Zfield1
*" VALUE(Zf2) LIKE Ztable-Zfiled2 OPTIONAL
*" VALUE(Zf3) LIKE Ztable-Zfield3 OPTIONAL
*"----
//
DATA : WTAB LIKE Ztable.
WTAB-Zfield1 = ZF1.
WTAB-Zfield2 = ZF2.
WTAB-Zfield3 = ZF3.
UPDATE ZTABLE FROM WTAB.
COMMIT WORK.
OR YOU CAN USE INSERT INTO ZTABLE VALUES WTAB.
ENDFUNCTION.
REGARDS
SHIBA DUTTA
‎2007 Apr 09 5:56 AM
Hi Rammohan,
thank you for immediat resp.
but I wanted to write my own logic/function for this requirement.
Regards
Gopi
‎2007 Apr 09 6:09 AM
SHIBA DUTTA ,
DATA IS NOT UPDATED
GOPI
Message was edited by:
Gopi Tiyyam
‎2007 Apr 09 6:47 AM
IF YOU WANT TO INSERT A NEW ROW THEN USE INSERT AND CHECK WHETHER THE DATA IS UPDATED OR NOT... FIRST OF ALL CHECK IN SE11 WHETHER YOU CAN ABLE TO INSERT THE DATA OR NOT .. GO TO SE11 GIVE ZTABLE NAME AND CHECK IN DELIVERY AND MAINTENANCE TAB WHETHER YOU DEFINE THE MAINTENANCE ALLOWED OR NOT ? THEN CHECK IN MENU UTILITIES--> TABLE CONTENTS->CREATE ENTRIES TO SAVE A DATA WHETHER YOU CAN INSERT THERE OR NOT... IF IT IS WORKING THEN USE WITH INSERT COMMAND...
REGARDS
SHIBA DUTTA
‎2007 Apr 06 4:08 PM
Hi Gopi,
Why to go for Coding?If the Table Maintenance Generator is set, you can update the table using Tcode : SM30 itself.
Hope this helps.
Thanks,
Srinivas