‎2008 May 09 9:17 PM
Hi,
I am new to ABAP Programming., i had created a function module with 5 import parameters enableing
optional and pass value options. I need to insert values to database. But function module contains only
the following statemet.
FUNCTION ZEMP_CREATE_NAME.
*"----
""Local Interface:
*" IMPORTING
*" VALUE(EMPID) TYPE ZEMPID OPTIONAL
*" VALUE(NAME1) TYPE ZNAME1 OPTIONAL
*" VALUE(ORT01) TYPE ORT01_GP OPTIONAL
*" VALUE(REGIO) TYPE REGIO OPTIONAL
*" VALUE(TELF1) TYPE TELF1 OPTIONAL
*" VALUE(STATUS) TYPE ZSTATUS OPTIONAL
*" VALUE(EPOSITION) TYPE ZPOSI OPTIONAL
*"----
insert into zemptable values('EMPID','NAME1','ORT01','REGIO','TELF1','ZSTATUS','ZPOSI')).
ENDFUNCTION.
Is this statement correct? Could someone guide me how to resolve this?
Thanks & Regards
Vijay
‎2008 May 09 9:22 PM
Check the F1 help for insert.
If you already Checked the program you know it's not right.
That looks ok for Standard SQL, but ABAP uses a special set of sql commands called open sql.
*edit
Sorry, didn't saw you were new at this, you don't want to pass that many parameters.
IF those 7 parameters make up the whole table is better to do either something like...
w_zemptable type zemptable in the importing parameters and then in the code just do
insert into zemptable values w_zemtables.
.... or better
in the tables section declare
i_zemptable like zemptable
and in the code
insert zemptable from table i_zemptable.
Edited by: Ramiro Escamilla on May 9, 2008 3:23 PM
‎2008 May 09 9:22 PM
Check the F1 help for insert.
If you already Checked the program you know it's not right.
That looks ok for Standard SQL, but ABAP uses a special set of sql commands called open sql.
*edit
Sorry, didn't saw you were new at this, you don't want to pass that many parameters.
IF those 7 parameters make up the whole table is better to do either something like...
w_zemptable type zemptable in the importing parameters and then in the code just do
insert into zemptable values w_zemtables.
.... or better
in the tables section declare
i_zemptable like zemptable
and in the code
insert zemptable from table i_zemptable.
Edited by: Ramiro Escamilla on May 9, 2008 3:23 PM
‎2008 May 09 11:13 PM
Hi Ramiro,
Thanks for your help. When i execuute my program i am able to provide values
to all the columns.,but its not inserting to the database. could you please tell
me what would be the problem?
This is my code
FUNCTION ZEMP_CREATE_NAME.
*"----
""Local Interface:
*" IMPORTING
*" VALUE(EMPID) TYPE ZEMPID OPTIONAL
*" VALUE(NAME1) TYPE ZNAME1 OPTIONAL
*" VALUE(ORT01) TYPE ORT01_GP OPTIONAL
*" VALUE(REGIO) TYPE REGIO OPTIONAL
*" VALUE(TELF1) TYPE TELF1 OPTIONAL
*" VALUE(STATUS) TYPE ZSTATUS OPTIONAL
*" VALUE(POSITION) TYPE ZPOSI OPTIONAL
*"----
Data i_zemptable like zemptable.
insert into zemptable values i_zemptable.
ENDFUNCTION.
Thanks & Regards
Vijay
‎2008 May 09 11:33 PM
Because you didn't made anything I told you.
i_zemptable is declared in the tables tab not in the code, get rid of all those importing parameters
‎2008 May 10 1:42 AM
Hi Ramiro,
I Kept the Import paramters and tried., the code works fine. The reason why i didnt modify my code
was i am going to access this function module using a webdynpage. Suggest me if an worng any where?
Thanks & Regards
Vijay
FUNCTION ZEMP_CREATE_NAME.
*"----
""Local Interface:
*" IMPORTING
*" VALUE(EMPID) TYPE ZEMPID
*" VALUE(NAME1) TYPE ZNAME1
*" VALUE(ORT01) TYPE ORT01_GP
*" VALUE(REGIO) TYPE REGIO
*" VALUE(TELF1) TYPE TELF1
*" VALUE(STATUS) TYPE ZSTATUS
*" VALUE(EPOSITION) TYPE ZPOSI
*"----
DATA i_zemptable like zemptable.
i_zemptable-EMPID = EMPID.
i_zemptable-NAME1 = NAME1.
i_zemptable-ORT01 = ort01.
i_zemptable-REGIO = REGIO.
i_zemptable-TELF1 = telf1.
i_zemptable-STATUS = STATUS.
i_zemptable-ePOSITiON = ePOSITiON.
insert into zemptable values i_zemptable.
commit work.
ENDFUNCTION.
‎2008 May 10 3:24 AM
Hi vijay!!
Try this if it helps:
DATA i_zemptable like zemptable.
i_zemptable-EMPID = EMPID.
i_zemptable-NAME1 = NAME1.
i_zemptable-ORT01 = ort01.
i_zemptable-REGIO = REGIO.
i_zemptable-TELF1 = telf1.
i_zemptable-STATUS = STATUS.
i_zemptable-ePOSITiON = ePOSITiON.
insert into zemptable-empid values i_zemptable-empid.
insert into zemptable-name1 values i_zemptable-name1.
insert into zemptable-ort01 values i_zemptable-ort01.
insert into zemptable-regio values i_zemptable-regio.
insert into zemptable-telf1 values i_zemptable-telf1.
insert into zemptable-status values i_zemptable-status.
insert into zemptable-eposition values i_zemptable-eposition.
append zemptable.
ENDFUNCTION.
kindly rewrd if useful
‎2008 May 13 8:37 PM
‎2008 May 14 9:29 AM
Hi Vijay!!
Hi vijay!!
I would like to edit the info i gave u .Though u got ur reply.Still to make it more clear:
Complete code will be like this:
DATA i_zemptable like zemptable.
i_zemptable-EMPID = EMPID.
i_zemptable-NAME1 = NAME1.
i_zemptable-ORT01 = ort01.
i_zemptable-REGIO = REGIO.
i_zemptable-TELF1 = telf1.
i_zemptable-STATUS = STATUS.
i_zemptable-ePOSITiON = ePOSITiON.
insert into zemptable values i_zemptable
ENDFUNCTION.
The flow of the programs goes like this:
parameters--> work area/header line -->Db Table
Here
Ur Import Parameters wrk as parameters.
i_zemptable is the work area
and
zemptable is the Database table.
So only One insert is required.
I guess u used this way only...let me knw also.
thnks
deepika
‎2008 May 14 9:08 PM
‎2008 May 10 7:25 AM
FUNCTION ZEMP_CREATE_NAME.
*"----
""Local Interface:
*" IMPORTING
*" VALUE(EMPID) TYPE ZEMPID OPTIONAL
*" VALUE(NAME1) TYPE ZNAME1 OPTIONAL
*" VALUE(ORT01) TYPE ORT01_GP OPTIONAL
*" VALUE(REGIO) TYPE REGIO OPTIONAL
*" VALUE(TELF1) TYPE TELF1 OPTIONAL
*" VALUE(STATUS) TYPE ZSTATUS OPTIONAL
*" VALUE(EPOSITION) TYPE ZPOSI OPTIONAL
*"----
insert into zemptable values('EMPID','NAME1','ORT01','REGIO','TELF1','ZSTATUS','ZPOSI')).
ENDFUNCTION.
Hi,
U can do like this
1 Defie a work area like given below
DATA wa type zemptable.
2 now put the values into wa.
wa-empid = empid. (wa-empid is the name of id field in zemptable )
-
-
-
wa-zposi = eposition. (wa-zposi is also the field in zemptable )
3 now insert this wa into ur table zemptable
insert zemptable from wa.
‎2008 May 14 9:44 AM
Hi,
Use this:
DATA i_zemptable like zemptable.
i_zemptable-EMPID = EMPID.
i_zemptable-NAME1 = NAME1.
i_zemptable-ORT01 = ort01.
i_zemptable-REGIO = REGIO.
i_zemptable-TELF1 = telf1.
i_zemptable-STATUS = STATUS.
i_zemptable-ePOSITiON = ePOSITiON.
insert into zemptable values i_zemptable.
commit work.
Reward points if helpful
‎2008 May 14 9:09 PM