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-table control

Former Member
0 Likes
686

Hi,

In Module pool prgraming iam using table control.

My problem is when i enter first record and press enter iam able to move to next line but my first or previous records are getting cleared. In the code i haven't cleared anywhere.

So i should hold the record whenever i press enter.

Please let me know.

Regards,

Mahesh.

7 REPLIES 7
Read only

I355602
Product and Topic Expert
Product and Topic Expert
0 Likes
657

Hi,

What you need to do is to modify the internal table from table control whenever a user action is performed.

Follow:-

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...

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. "<--read internal table into table control
  ENDLOOP.
 
PROCESS AFTER INPUT.
*  MODULE user_command_8003.
 
  LOOP WITH CONTROL po_tab.
    MODULE modify_data. "<--modify internal table from table control
  ENDLOOP.

In PBO:-


*&---------------------------------------------------------------------*
*&      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

Now when you add some records into table control and perform any user action, the records will retain.

Hope this helps you.

Regards,

Tarun

Read only

Former Member
0 Likes
657

Hi,

Here iam modifying the customized ztable from internal table. Data is getting inserted into the table correctly but here my problem is while entering in the table control if suddenly i press enter key then my whole data entered in the table control is getting cleared visibilly but internally its holding the data and when i save it, it is moved into the ztable.

So why it is getting cleared visibilly when i press enter key. where iam doing mistake.

Please let me know.

Read only

I355602
Product and Topic Expert
Product and Topic Expert
0 Likes
657

Hi,

>

> Hi,

> Here iam modifying the customized ztable from internal table. Data is getting inserted into the table correctly but here my problem is while entering in the table control if suddenly i press enter key then my whole data entered in the table control is getting cleared visibilly but internally its holding the data and when i save it, it is moved into the ztable.

> So why it is getting cleared visibilly when i press enter key. where iam doing mistake.

> Please let me know.

If you read data in PBO and modify the data in PAI at any user action.

Then there seems no reason that the data disappers from the table control when you hit ENTER key.

Just follow the concept as in my previous reply.

As in my case the code is working perfectly.

Hope this helps you.

Regards,

Tarun

Read only

Former Member
0 Likes
657

already existing one if i follow what u said is ok working fine but if i INSERT a complete new records for a new gate pass no (for example) then what should i follow.

Please let me know.

Read only

I355602
Product and Topic Expert
Product and Topic Expert
0 Likes
657

Hi,

Refer:-

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. "<--save into db_table

In PBO:-


*&---------------------------------------------------------------------*
*&      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. "<--insert + update
      A = SY-DBCNT.
      IF SY-SUBRC = 0.
        MESSAGE S008 WITH A.
      ENDIF.
  ENDCASE.

ENDMODULE.                 " SAVE_DATA  INPUT

Using the modify statement, if records are found based on the primary key combination, then the records are updated else they are inserted into the database table.

Hope this helps you.

Regards,

Tarun

Read only

Former Member
0 Likes
657

Here whatever u declare in PAI in table control loop simultaneously u have to declare this in the PBO loop also bcoz when u press enter the execution starts from PBO.

Ex: Declare the fields with some parameter even though u define them from dictionary fields and move the data into the internal table and also in PBO move the data from internal table to the field parameters.

Now when u press enter ur data will not be cleared.

Thanks for ur reply.