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

DDIC - Insert

Former Member
0 Likes
2,484

Hi Friends,

Could any one pls guide me as to how to insert the following data in the table PA0000, through a customized dialog program.

Field Name Values

-


-


PERNR 12345

SUBTY 1

OBJPS 1

SPRPS 1

ENDDA 01.12.2006

BEGDA 02.12.2006

SEQNR 1

Kindly explian me in detail as to how to insert the above details in the table PA0000.

TTIA.

Regards,

Mark K

24 REPLIES 24
Read only

Former Member
0 Likes
2,436

Hi Mark ,

Here are the steps for the same.

1. Create a screen which has the elements you want to insert into the table.

2. Along with the elements add a button , which when pressed inserts the data.

3. in the PAI module , when sy-ucomm/okcode is same as that of your button

insert the data into the table using SQL commands.

Hope this gives you an idea of what is to be done,.

Regards

Arun

Read only

Sandeep_Panghal
Product and Topic Expert
Product and Topic Expert
0 Likes
2,436

Hi Mark,

Try:

INSERT { {INTO target VALUES source }

| { target FROM source } }.

Insert PA0000 from it_values.

Build it_vales with the specified values.

Hope this helps.

Read only

0 Likes
2,436

Could u pls give me in detail the example for the given data (the fields mentioned earlier.)

Regards,

Read only

0 Likes
2,436

Hi Mark ,

Do you want a dailog program or will a report do where you upload data from a flat file and update it.

Regards

Arun

Read only

0 Likes
2,436

I need dialog program.

Kindly guide me.

Regards,

Read only

0 Likes
2,436

Hi Mark ,

So this means you need to create a module pool .

So as i said in the first reply you need to create a screen , and write your code in the PAI module.

For more details please look at the help of module pool programming.

One you are done with creating the screen i can help you further.

Reagrds

Arun

Read only

0 Likes
2,436

I have created the screen and able to enter the data. I am able to insert the entered data into PA0003 on pressing the save button. But the table PA0000 is not getting saved.

Regards,

Read only

0 Likes
2,436

Hi Mark ,

Please debug the program and see what is the sy-subrc when you try to insert data into the table.

If possible could you please paste the code for that section here.

Regards

Arun

Read only

0 Likes
2,436

Hi Arun,

The complete code is as follows.

&----


*& Module pool ZPA_EMP

*&

&----


PROGRAM ZPA_EMP.

TABLES : PA0000, PA0003, PA0001.

data : BEGIN OF IT_PA0000 OCCURS 0,

PERNR LIKE PA0000-PERNR,

SUBTY LIKE PA0000-SUBTY,

OBJPS LIKE PA0000-OBJPS,

SPRPS LIKE PA0000-SPRPS,

ENDDA LIKE PA0000-ENDDA,

BEGDA LIKE PA0000-BEGDA,

SEQNR LIKE PA0000-SEQNR,

AEDTM LIKE PA0000-AEDTM,

UNAME LIKE PA0000-UNAME,

HISTO LIKE PA0000-HISTO,

ITXEX LIKE PA0000-ITXEX,

REFEX LIKE PA0000-REFEX,

ORDEX LIKE PA0000-ORDEX,

ITBLD LIKE PA0000-ITBLD,

PREAS LIKE PA0000-PREAS,

FLAG1 LIKE PA0000-FLAG1,

FLAG2 LIKE PA0000-FLAG2,

FLAG3 LIKE PA0000-FLAG3,

FLAG4 LIKE PA0000-FLAG4,

RESE1 LIKE PA0000-RESE1,

RESE2 LIKE PA0000-RESE2,

GRPVL LIKE PA0000-GRPVL,

MASSN LIKE PA0000-MASSN,

MASSG LIKE PA0000-MASSG,

STAT1 LIKE PA0000-STAT1,

STAT2 LIKE PA0000-STAT2,

STAT3 LIKE PA0000-STAT3,

END OF IT_PA0000.

&----


*& Module STATUS_0100 OUTPUT

&----


  • text

----


MODULE STATUS_0100 OUTPUT.

SET PF-STATUS 'GUI'.

  • SET TITLEBAR 'xxx'.

ENDMODULE. " STATUS_0100 OUTPUT

&----


*& Module USER_COMMAND_0100 INPUT

&----


  • text

----


MODULE USER_COMMAND_0100 INPUT.

DATA : OK_CODE LIKE SY-UCOMM.

CASE OK_CODE.

WHEN 'SAVE'.

INSERT PA0003.

COMMIT WORK.

MOVE : PA0003-PERNR TO IT_PA0000-PERNR,

PA0003-SUBTY TO IT_PA0000-SUBTY,

PA0003-OBJPS TO IT_PA0000-OBJPS,

PA0003-SPRPS TO IT_PA0000-SPRPS,

PA0003-ENDDA TO IT_PA0000-ENDDA,

PA0003-BEGDA TO IT_PA0000-BEGDA,

PA0003-SEQNR TO IT_PA0000-SEQNR.

IT_PA0000-AEDTM = IT_PA0000-BEGDA.

IT_PA0000-UNAME = space.

IT_PA0000-HISTO = space.

IT_PA0000-ITXEX = space.

IT_PA0000-REFEX = space.

IT_PA0000-ORDEX = space.

IT_PA0000-ITBLD = space.

IT_PA0000-PREAS = space.

IT_PA0000-FLAG1 = space.

IT_PA0000-FLAG2 = space.

IT_PA0000-FLAG3 = space.

IT_PA0000-FLAG4 = space.

IT_PA0000-RESE1 = space.

IT_PA0000-RESE2 = space.

IT_PA0000-GRPVL = space.

IT_PA0000-MASSN = 'L1'.

IT_PA0000-MASSG = space.

IT_PA0000-STAT1 = space.

IT_PA0000-STAT2 = '3'.

IT_PA0000-STAT3 = '1'.

APPEND IT_PA0000.

loop at it_pa0000.

Insert PA0000. " from it_PA0000.

endloop.

commit work.

WHEN 'BACK' OR 'EXIT' OR 'CANCEL'.

LEAVE PROGRAM.

ENDCASE.

ENDMODULE. " USER_COMMAND_0100 INPUT

-


Kindly check the above code and give a solution.

Regards,

Read only

0 Likes
2,436

Hi Mark ,

Code seems to be OK .

Could you please put a break point at the INSERT statement and check what is the value of sy-subrc that is returned.

Please also check that the values you are entering are in the check table for each field.

Regards

Arun

Read only

0 Likes
2,436

Before to the insert command, the data is available in the internal table.

I tried by giving the break-point at insert, it goes through the code, but not getting inserted into the table.

I could not understand what is the reason.

Kindly look into this.

Regards,

Read only

0 Likes
2,436

Hi Mark ,

Please do the following

1. Once in the loop , before the insert command, please check what is the content of the header.

2. After executing the insert command , please check the value of <b>SY-SUBRC</b>.

If possible please tell me the values of the same.

Thanks

Arun

Read only

0 Likes
2,436

Hey Mark ,

Why have you commented <b>from it_PA0000</b>. in the statement Insert PA0000. " from it_PA0000.

instead of from it must be <b>values it_PA0000</b>

Please do tell me if it helps

Reagrds

Arun

Read only

0 Likes
2,436

I checked the sy-subrc before insert and after insert, and the value I am getting is 0. The code written to find sy-subrc is as follows.

loop at it_pa0000.

cnt = sy-subrc.

Insert PA0000.

commit work.

cnt1 = sy-subrc.

endloop.

But the data is not inserted into the table PA0000.

Regards,

Read only

0 Likes
2,436

Hey mark ,

Please try thr code

<b>Insert PA0000 values it_PA0000 .</b>

instead of Insert PA0000.

Please tell me if it helps or not

Regards

Arun

Read only

0 Likes
2,436

LOOP AT IT_PA0000.

INSERT into PA0000 values it_PA0000.

COMMIT WORK.

ENDLOOP.

I tried like the above, but I am getting the error as following while activating.

" The work area "IT_PA0000" is not long enough. long enough."

What to do? Pls

Regards,

Read only

0 Likes
2,436

Hi Mark ,

The reason for this is that the structure of your internal table and table PA000 is not the same .

Since you are using the same field name , so i suggest u change the structure of your internal table same as PA000 , now if u do not want to do it create an other internal table with structure same as PA000 , and insert values into this new internal table from your existing internal table .

Use this new internal table to insert values into the table.

Regards

Arun

Read only

0 Likes
2,436

I tried like the below, but no effect.

*LOOP AT IT_PA0000.

INSERT PA0000 from it_pa0000.

COMMIT WORK.

  • ENDLOOP.

Regards.

Read only

0 Likes
2,436

have you changed the structure of it_pa0000 ,

and the command is <b>INSERT into PA0000 values it_PA0000</b> and not what you have tried.

if this does not work please try using the command

MODIFY pa0000 FROM it_pa0000.

Please tell me the result

Reagrds

Arun

Read only

0 Likes
2,436

Hi Arun,

I tried all the suggestion, but still the data is not getting inserted into table PA0000.

Regards,

Read only

0 Likes
2,436

Hi Mark ,

Is sy-subr = 0 , after the insert command is executed.

Regards

Arun

Read only

0 Likes
2,436

Yes. Sy-subrc = 0.

Regards,

Read only

0 Likes
2,436

Hi Mark ,

Coule you please send me the modified code of the PAI module.

Regards

Arun

Read only

Sandeep_Panghal
Product and Topic Expert
Product and Topic Expert
0 Likes
2,436

Hi Mark,

Try this:

Once u build the internal table , insert pa0000 values it_tab.

One more thing no need of loop and enloop.