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

Save data in module pool

Former Member
0 Likes
4,967

Hi All,

I have made a screen in module pool. Whenever I enter data on my screen fields and click save button, the data should get saved . I do not have to update any DB table.

Please suggest what more code should be written in PAI:

case sy-ucomm.

when 'SAVE'

....

...

Every useful aswer will be rewarded.

Abhimanyu

8 REPLIES 8
Read only

I355602
Product and Topic Expert
Product and Topic Expert
0 Likes
2,178

Hi Abhimanyu,

Take the names of the input/output fields as work_area-field_name.

Use code, its working:-

In PAI,


PROCESS AFTER INPUT.
  MODULE USER_COMMAND_8003.

  LOOP WITH CONTROL PO_TB. "po_tb is name of table control
    MODULE INSERT_DATA. "to insert data from table control into internal table
  ENDLOOP.


*&---------------------------------------------------------------------*
*&      Module  INSERT_DATA  INPUT
*&---------------------------------------------------------------------*
MODULE INSERT_DATA INPUT.
  APPEND WA_ZEKPO TO IT_ZEKPO.
  "append data from work area fields into internal table on user command
ENDMODULE.                 " INSERT_DATA  INPUT

Hope this solves your problem.

Thanks & Regards,

Tarun Gambhir

Read only

GauthamV
Active Contributor
0 Likes
2,178

module USER_COMMAND_0100 input.


case sy-ucomm.

when 'DISP'.

select name city salary role from ztable into table it_data
where name = wa_data-name.

read table it_data into wa_data with key name = wa_data-name.

when 'INS'.

WA_DATA-NAME = ztable-NAME.
WA_DATA-city = ztable-city .
WA_DATA-salary = ztable-salary.
WA_DATA-role = ztable-role.

append wa_data to it_data.
clear wa_data.

insert ztable from table it_data.

IF sy-subrc = 0.

  MESSAGE 'records created succesfully' TYPE 'S'.

ENDIF.

when 'SAVE'.
modify ztable from ztable.

if sy-subrc = 0.

message 'record updated succesfully' type 'S'.

endif.

Endcase.
endmodule.                 " USER_COMMAND_0100  INPUT
Read only

Former Member
0 Likes
2,178

Hi abhimanyu...

Your screen fields will refer a dictionary structure...and you need to have a work area were ,you can transport the statemnt from screen to work area using FIELD statements .

e,g FIELD (SCREENFIELD NAME)

Read only

Former Member
0 Likes
2,178

Hi,

Just pass the values of corresponding screen fields to the table fields in the loop.

Hope it helps!!

let me know if you still not clear!!

Regards,

Pavan

Read only

Former Member
0 Likes
2,178

Hi,

When save just insert the internal table row into db table after the validation using INSERT stmt.

Do the insertion into the loop stmt.

I hope this will help u.

Thanks.

Read only

Former Member
0 Likes
2,178

HI....

I do not have to update table....

Data should remain on the screen when the screen is opened again.

Read only

0 Likes
2,178

>

> HI....

>

> I do not have to update table....

>

> Data should remain on the screen when the screen is opened again.

Make the screen fields global and pass the data into it.

Read only

Former Member
0 Likes
2,178

done