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

Module Pool

Former Member
0 Likes
1,199

Hi,

I want to read data from a data base table, and displayed it in screen fields, also I want to Add, Modify and delete from database

So please give me the

Links or Exaplel of data base managing Module pool program

Regards

Nausal

14 REPLIES 14
Read only

Former Member
0 Likes
1,156

try using editable alv or table control.

Read only

mvoros
Active Contributor
0 Likes
1,156

Hi,

why don't you use Table maintenance generator? You can generate maintenance view for your table in SE11 and then modify your table in SM30. There are some event which can be used to enhance standard maintenance view. If you need some extra logic which you can not achieve via events, then it will be good example for you how to develop your own solution. Just look for maintenance view in SAP documentation.

Cheers

Read only

Former Member
0 Likes
1,156

Hi,

You can handle database through PAI & PBO events. These events will be created along with your module pool program. You can write your normal programming in the above events.

PBO: Process Before Output is used before initilisation of screen

PAI: Process After Input: this will trigger after input is processed (i.e. When you submit the data inOtherWords: Event Trigger)

In these events you can access your screen UI elements by using their ID's.

For Development use SE80 for easy development.

Best Regards

Ravi

Read only

Former Member
0 Likes
1,156

Hi,

write program You can featch records through select statment and after getting use modify and delete for modifing and deleteing records.

Regards

Md.MahaboobKhan

Read only

0 Likes
1,156

Hi,

I have a custom table ZTECH

In which ther is number of fields consider only one field as TNAME (STRING FIELD)

I want to print it in screen field named

TNAME.

pleace give an example code to do this

Regards

Nausal

Read only

I355602
Product and Topic Expert
Product and Topic Expert
0 Likes
1,156

Hi,

A small example to read data from a ztable and display in a table control.

Also when user modifies any records and any user action is performed the internal table is modified and if the user clicks SAVE button database table is modified.

Also user can add new records to internal table and modify the zdatabase table when SAVE button is clicked.

it_zekpo is my internal table w/o header line,

wa_zekpo is work area.

Name of input/output fields on screen are:-

wa_zekpo-field1,

wa_zekpo-field2, and so on...

Take a button on the screen with function-code SAVE or in the pf-status take the function code of the standard save button as SAVE.

Use code:-

At screen logic:-


PROCESS BEFORE OUTPUT.
  MODULE status_8003.
 
  LOOP WITH CONTROL po_tab. "po_tab is table control on screen 8003
    MODULE read_data.
  ENDLOOP.
 
PROCESS AFTER INPUT.
*  MODULE user_command_8003.
 
  LOOP WITH CONTROL po_tab.
    MODULE modify_data.
  ENDLOOP.

  MODULE SAVE_DATA.

In PBO:-


*&---------------------------------------------------------------------*
*&      Module  STATUS_8003  OUTPUT
*&---------------------------------------------------------------------*
MODULE status_8003.
  SET PF-STATUS 'ZPF_STAT'.
ENDMODULE.                 "STATUS_8003  OUTPUT
*&---------------------------------------------------------------------*
*&      Module  READ_DATA  OUTPUT
*&---------------------------------------------------------------------*
MODULE read_data OUTPUT.
  READ TABLE it_zekpo INTO wa_zekpo INDEX po_tab-current_line. "po_tab is table control name
 
  data : line_count type i.
 
  describe it_zekpo
  lines line_count.
 
  po_tab-lines = line_count + 10.
  "to increase the number of lines in table control dynamically
 
ENDMODULE.                 " READ_DATA  OUTPUT

In PAI:-


*&---------------------------------------------------------------------*
*&      Module  MODIFY_DATA  INPUT
*&---------------------------------------------------------------------*
MODULE MODIFY_DATA INPUT.
  MODIFY IT_ZEKPO FROM WA_ZEKPO INDEX po_tab-currentline.
  "this will modify the contents of existing line
ENDMODULE.                 " MODIFY_DATA  INPUT

*&---------------------------------------------------------------------*
*&      Module  SAVE_DATA  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE SAVE_DATA INPUT.

  DATA : A LIKE SY-DBCNT.
  OK_CODE = SY-UCOMM.
  CASE OK_CODE.
    WHEN 'SAVE'. "function code for SAVE button
      MODIFY ZEKPO FROM TABLE IT_ZEKPO.
      A = SY-DBCNT.
      IF SY-SUBRC = 0.
        MESSAGE S008 WITH A.
      ENDIF.
  ENDCASE.

ENDMODULE.                 " SAVE_DATA  INPUT

Hope this helps you.

Regards,

Tarun

Read only

Former Member
0 Likes
1,156

Hello Nausal,

You can get fields fetched from database into Screen Fields.

1. Get into the layout and while setting the screen fields, double-click screen field and select the check-boxes SET PARAMETER and GET PARAMETER.

2. In TOP-Include, define those parameters by the same name in DATA section. Eg: On screen you give the name P_CARRID for one field, define same name in TOP-INCLUDE DATA: P_CARRID TYPE CHAR10.

3. Run Select query in PBO and run a READ statement on the field which you want to push in screen fields, and simultaneously assign those values in screen fields.

4. No sooner, you execute the program by executing the transaction. It automatically gets the values in the screen fields.

Hope it helps you.

Zahack

Read only

0 Likes
1,156

Hi Zahack,

Thanks for your support,

Now I am able to take the records and display it in screen fields

my selection is based on purchase order number

is it any possible way to convert Text field to SELECT-OPTIONS used in report program

Regards

Nausal

Read only

0 Likes
1,156

ASKWR Nausal,

To make Text-fields as select-options, you can do a simple exercise;

Create a Sub-screen and code SELECT-OPTIONS in its code part.

Just follow step-by-step procedure given in the below link.

[SELECT-OPTIONS in MODULE POOL|http://sample-code-abap.blogspot.com/2008/06/select-option-in-module-pool-screen.html]

Hope it helps you.

Zahack

Read only

0 Likes
1,156

Hi Zahack,

Thanks For Your Support

Regards

Nausal

Edited by: Nausal Usman on Mar 24, 2009 2:51 PM

Read only

Former Member
0 Likes
1,156

Hi,

Check out this wiki, help you to develop table control step by step..... it includes all functionality which you need.

https://www.sdn.sap.com/irj/scn/wiki?path=/display/abap/learn%252bmaking%252bfirst%252btable%252bcon...

Thanks,

Krishna...

Read only

former_member376453
Contributor
0 Likes
1,156

Hi - you can go through any basic documentation of module pool, I think you will receive all your answers. Better go through this and ask any specific question if you have to this forum.

Kuntal

Read only

sarbajitm
Contributor
0 Likes
1,156

Search Code Gallery With Insertion of Data using Table Control. You get a code snippet developed by Niloy Sarkar. It may be helpful.

Regards.

Sarbajit.

Read only

Former Member
0 Likes
1,156

Thanks for All