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 programming

Former Member
0 Likes
1,663

Hi all,

i am using some fields to e shown on table in module pool,

upon hitting enter, it should gets displayed in my table,

the problem is that, when i hits "enter", it is displaying my data

but again successive, it again displays all these entries.

But i wants that, after first enter, it should not come again

after any enter hits.

wa_final-sno   = '1'.
wa_final-description  = 'Material'.

wa_final-subject = 'Billing'.
APPEND wa_final TO it_final.
CLEAR wa_final.

wa_final-sno   = '2'.
wa_final-description  = 'Goods'.

wa_final-subject = 'Inputs'.
APPEND wa_final TO it_final.
CLEAR wa_final.


wa_final-sno   = '3'.
wa_final-description  = 'Cost'.

wa_final-subject = 'Value'.
APPEND wa_final TO it_final.
CLEAR wa_final.

WRITE : / WA_FINAL-SNO, WA_FINAL-DESCRIPTION wa_final-subject.


CLEAR : WA_FINAL.

1 ACCEPTED SOLUTION
Read only

former_member187748
Active Contributor
0 Likes
1,631

Hi Shweta,

you can create a 

PROCESS_ON_VALUE-REQUEST

in the PAI of your program,

then code in your main program to get those data.

16 REPLIES 16
Read only

Former Member
0 Likes
1,631

Hi,

Before append statement, check whether the entry already exists in internal table or not. If not, only then append the entry.

or use MODULE on request.

Regards,

DPM

Read only

0 Likes
1,631

Hi Debopriyo,

i am not getting your points, please elaborate how could i do that.

Read only

0 Likes
1,631

wa_final-sno                = '1'.
wa_final-description   = 'Material'.

wa_final-subject          = 'Billing'.


  READ TABLE it_final INTO wa_final1 WITH KEY subject = wa_final-subject.

     IF sy-subrc <> 0.
        APPEND wa_final TO it_final.

   ENDIF.
CLEAR wa_final.

Read only

0 Likes
1,631

Hi,

i have written according to you, but initially it_final is empty,

so it returns sy-subrc = 4.

So not fetching data, i have written like this, please tell me whats wrong with this code.

I have to declare another internal table or else.

wa_final-sno   = '1'.
wa_final-description  = 'Material'.

wa_final-subject = 'Billing'.


READ TABLE IT_FINAL INTO WA_FINAL WITH KEY SNO = WA_FINAL-SNO.
IF SY-SUBRC = 0.
APPEND wa_final TO it_final.
ENDIF.
CLEAR wa_final.

wa_final-sno   = '2'.
wa_final-description  = 'Goods'.

wa_final-subject = 'Inputs'.


READ TABLE IT_FINAL INTO WA_FINAL WITH KEY SNO = WA_FINAL-SNO.
IF SY-SUBRC = 0.
APPEND wa_final TO it_final.
ENDIF.
CLEAR wa_final.


wa_final-sno   = '3'.
wa_final-description  = 'Cost'.

wa_final-subject = 'Value'.

READ TABLE IT_FINAL INTO WA_FINAL WITH KEY SNO = WA_FINAL-SNO.
IF SY-SUBRC = 0.
APPEND wa_final TO it_final.
ENDIF.
CLEAR wa_final.

Read only

0 Likes
1,631

Hi,

You should not use serial number for comparision, either use description or subject.

I think I mistyped '=' instead of  '<>' , in my previous thread.

okay put another check

IF NOT it_final[] IS INITIAL.

         READ TABLE IT_FINAL INTO WA_FINAL WITH KEY SNO = WA_FINAL-SNO.

                 IF SY-SUBRC <>  0.

                   APPEND wa_final TO it_final.

                 ENDIF.

ELSE.

APPEND wa_final TO it_final.
ENDIF.

Regards,

DPM

Read only

0 Likes
1,631

Hi Debopriyo,

one more thing i have created a z table, along with above data, there are some more

fields, which will be entered by user, and after that i wants to save those data

in my ztable, what can i do.

Let say i have some fields say fld1, and fld2 that will be entered by user on run time

now, along with above mentioned field i wants to save these fields in my ztable.

How could i achieve this ?

Read only

Former Member
0 Likes
1,631

hi Shweta Chouhan,

Just sort the internal table and delete the adjacent duplicates from the internal table...

sort itab ascending by filedname1 fileldname2......

delete adjacent duplicates from itab comparing fileldnale1........

It solves your issue...

Any further queries??

Thanks,

Vijay SR

Read only

former_member187748
Active Contributor
0 Likes
1,632

Hi Shweta,

you can create a 

PROCESS_ON_VALUE-REQUEST

in the PAI of your program,

then code in your main program to get those data.

Read only

0 Likes
1,631

Hi Sanjeev,

thanks a lot, i have solved it, now can you please tell me how could i save my data

in a ztable, when some entries has been done in table control .

Read only

0 Likes
1,631

In PAI,

IF sy-ucomm = 'SAVE'.

     IF it_final IS NOT INITAIL.

          MODIFY ztable FROM it_final.

     ENDIF.

ENDIF.

Read only

0 Likes
1,631

Create PF Status with SAVE button.

Then in PAI write the function of save button.

if sy-ucomm = 'SAVE'.

  if it_final is not initial.

   insert ztab from table it_final.

  endif.

endif

Read only

0 Likes
1,631

Hi Shweta,

here i am showing you a sample code, please change it accordingly

inside MODULE USER_COMMAND_9000 INPUT

write this code logic

CASE SY-UCOMM.

     WHEN 'ENTER'.

       PERFORM DISPLAY_DATA.

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

       LEAVE TO SCREEN 0.

     WHEN 'SAVE'.

       PERFORM SAVE_DATA.

     ENDCASE.

CLEAR : SY-UCOMM.


Now write a FORM SAVE_DATA as shown below


FORM SAVE_DATA .


LOOP AT IT_FINAL INTO WA_FINAL.

your ztable work area-MANDT = SY-MANDT.

your ztable work area-field1 = your final table work area-field1.

your ztable work area-field2 = your final table work area-field2.

your ztable work area-field3 = your final table work area-field3.

your ztable work area-field4 = your final table work area-field4.

MODIFY ZTABLE FROM your ztable work area.

ENDLOOP.

CLEAR your ztable work area.

ENDFORM

Read only

Former Member
0 Likes
1,631

Hi,

Replace you PAI logic as below,

Data : w_line type int4.

describe table it_cra lines w_lines.

  if tc-current_line > w_lines.

    append wa_final to it_final.

  else.

    modify it_final  from wa_final index tc-current_line.

  endif.

Regards,

Read only

Former Member
0 Likes
1,631

Hi shweta,

wa_final-sno   = '1'.
wa_final-description  = 'Material'.

wa_final-subject = 'Billing'.
APPEND wa_final TO it_final.
CLEAR wa_final.

wa_final-sno   = '2'.
wa_final-description  = 'Goods'.

wa_final-subject = 'Inputs'.
APPEND wa_final TO it_final.
CLEAR wa_final.


wa_final-sno   = '3'.
wa_final-description  = 'Cost'.

wa_final-subject = 'Value'.
APPEND wa_final TO it_final.
CLEAR wa_final.


sort it_final ascending.                    "Insert these lines , it will work for the multiple entry for each enter key


delete adjacent duplicates from it_final.

WRITE : / WA_FINAL-SNO, WA_FINAL-DESCRIPTION wa_final-subject.


CLEAR : WA_FINAL..


Thanks,

Vijay SR

Read only

0 Likes
1,631

Hi Vijay,

i have tried this already, but not working.

Read only

0 Likes
1,631

This message was moderated.