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

Problem in Module Pool Program

Former Member
0 Likes
1,152

Hi,

i need help for module pool program that is ,

how to send the data to data base table through module pool program,

i already created own database table,in that module pool program i created input/output boxs now we have to give the values on that boxs after click on the submit button taht values are display on the data base table .This is my requirement i tried to write so many types of insert statements but i'm not getting the output.

can anyone plz slove this problem.

Regards,

soni.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,132

There is a lot missing from the description of your problem, however, the basic process would be to

Data Area


tables: your_table.

data:
  sv_your_table like  your_table.

Get your data


select * from your_table where key = my_key.
if sy-subrc = 0.
 sv_your_table =  your_table.
else.
 clear sv_your_table.
endif.

Use the same fields in your_table on the screen in the screen painter hit F6. enter your_table and enter. Select the fields you want on the screen. then the Green Check.

Now..in your PAI Module of the screen when you call your USER_COMMAND module and intercept the OK_CODE to Save it


  if sv_your_table ne  your_table.
     modify your_table.        "If you are adding(inserting)  then    insert your_table.   although Modify will work as well.
     if sy-subrc NE 0
       message <your message for bad add/update>.
     else.
       message <your message for good add/update>.
     endif.
  endif.

12 REPLIES 12
Read only

Former Member
0 Likes
1,132

When u r writting to data base table. After INSERT or UPDATE you should use commit. then Only it will display in database.

Try this option. It will work.

Thanks

Read only

Former Member
0 Likes
1,133

There is a lot missing from the description of your problem, however, the basic process would be to

Data Area


tables: your_table.

data:
  sv_your_table like  your_table.

Get your data


select * from your_table where key = my_key.
if sy-subrc = 0.
 sv_your_table =  your_table.
else.
 clear sv_your_table.
endif.

Use the same fields in your_table on the screen in the screen painter hit F6. enter your_table and enter. Select the fields you want on the screen. then the Green Check.

Now..in your PAI Module of the screen when you call your USER_COMMAND module and intercept the OK_CODE to Save it


  if sv_your_table ne  your_table.
     modify your_table.        "If you are adding(inserting)  then    insert your_table.   although Modify will work as well.
     if sy-subrc NE 0
       message <your message for bad add/update>.
     else.
       message <your message for good add/update>.
     endif.
  endif.

Read only

Former Member
0 Likes
1,132

Not sure of your problem but here is my guess for a rather simplistic solution...

1) Declare the database table using the TABLES statement in your module pool program.

2) Make sure the fields on your screen have the same name as the TABLE-FIELDNAME

3) In the PAI of the screen, during debug, you should now see your table structure populated with the values entered on the screen.

4) These values can now be inserted in the database table using the INSERT statement.

Read only

Former Member
0 Likes
1,132

Thank's for replay,

but i need to write the code under this case statement ,

case sy-ucomm.

when 'submit'.

......................

......................

......................

when 'exit'.

leave program.

endcase.

we have to give the values on the I/O boxs after press the submit button that values r display on the database table.

i tried this way ..

INSERT ZREGISTRATION.

ZREGISTRATION-FIRSTNAME = 'xxxx'.

ZREGISTRATION-LASTNAME = 'xxxx'.

ZREGISTRATION-EMAILID = 'xxxxx@GMAIL.COM'.

ZREGISTRATION-HOME = 'xxxxxx'.

ZREGISTRATION-MOBILE = 'xxxxx'.

ZREGISTRATION-STREET = 'xxxxx'.

ZREGISTRATION-CITY = 'xxxxx'.

ZREGISTRATION-STATE = 'xxxx'.

ZREGISTRATION-PINCODE = 'xxxx'.

but my requirement is we r giving unlimited values on that I/O boxes ....

regards,

soni.

Read only

0 Likes
1,132

You have the Insert in the wrong place in the code you provided. I should be like this.


ZREGISTRATION-FIRSTNAME = 'xxxx'.
ZREGISTRATION-LASTNAME = 'xxxx'.
ZREGISTRATION-EMAILID = 'xxxxx@GMAIL.COM'.
ZREGISTRATION-HOME = 'xxxxxx'.
ZREGISTRATION-MOBILE = 'xxxxx'.
ZREGISTRATION-STREET = 'xxxxx'.
ZREGISTRATION-CITY = 'xxxxx'.
ZREGISTRATION-STATE = 'xxxx'.
ZREGISTRATION-PINCODE = 'xxxx'.

INSERT ZREGISTRATION.          " Moved to here

Read only

0 Likes
1,132

Hi,

u r right , but i need to send number of values to database ....

Regards,

soni

Read only

0 Likes
1,132

Hi,

how many times i'm writing like that coding so this is very lindy process ...

Read only

0 Likes
1,132

I am not sure if you are hardcoding the values in your program.

Well, If your are using input/ouput box (fields) on the screen....

any time the user enters a value and clicks submit....data would be stored into the table.

You are not required to hardcode.

You can dynamically enter values on the screen.

But if your question was about saving multiple records at a time......

how can that be possible with I/O box?

Well, I think it takes one record at a time.You have to have a table control to do this

So you can enter multiple records in table control and update them all at once.

I hope it helps.

Thanks.

Read only

0 Likes
1,132

Hi,

Well, If your are using input/ouput box (fields) on the screen....

any time the user enters a value and clicks submit....data would be stored into the table.

yes this is my problem sorry i could't explain properly , but i need this answer ..

Can u plz answer this question ..

Read only

0 Likes
1,132

soni,

I already did that. It was in my earlier post.

If you have selected Read-only option for the box on the screen then it would only display values but will not let user to enter values.

Please go to SE51 Layout ->Help-> Applicayion Help.

I hope it helps.

thanks.

Read only

0 Likes
1,132

You may want to clear ZSREGISTRATION after the insert. This way the screen will be ready for the next input. You may also want to validate the input before inserting them in the database in a MODULE during PAI.

Also, what is the key for the your database table ZREGISTRATION? Are you using a number object to have a sequential key?

Read only

Former Member
0 Likes
1,132

Hi,

For the OK_CODE of your SUBMIT button Your have to use your insert/modify statement.

Declare these

DATA: OK_CODE TYPE SY-UCOMM,
      SAVE_OK TYPE SY-UCOMM.

Then

CLEAR SAVE_OK.
    SAVE_OK = OK_CODE.
    CLEAR OK_CODE.
   CASE SAVE_OK.
       WHEN 'SUBT'.    "okcode of your submit button
          *insert stmt*     
       WHEN OTHERS.
          CALL SCREEN 0.
   ENDCASE.

Only when the users clicks sumit data has to be saved.

Hence the user action is required to be caught with okcode and tell the the system what to do.

I hope it helps.

thanks