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 with Loop at Screen

Former Member
0 Likes
1,713

Hi Experts,

I am doing a report : where when we trigger execute button the event have to trigger in selection-screen itself.

Os I have used : sscrfields-ucomm, AT SELECTION-SCREEN , AT SELECTION-SCREEN OUTPUT ( Loop at screen )

Note: I am not using modulepool, Just used select-options , paramters and ModifID then Loop at Screen.

Suppose my Selection-screen looks like:

Personal No:       1245   
Emplayee name     :       XYZ 
Posting date          :       01.01.2009

Eligible amount      :   2000           "this will fetched from Z table  
Amount paid         :   500             " manully entered by user --> then saved to z table
Balance amount   :   1500           " Eligible amount  - Amount paid

Eligible amount1    :   2000          " this will fetched from Z table 
amount paid1        :   750             " manully entered by user --> then saved to z table
Balance amount1  :   1500           " Eligible amount  - Amount paid

Next time when the user open the T-code and check for Personal No: 1245

my screen should look like.

Personal No:       1245   
Emplayee name     :        XYZ 
Posting date          :        01.01.2009

Eligible amount      :   1500            "this will fetched from Z table  
Amount paid         :                       " manully entered by user --> then saved to z table
Balance amount    :   1500            " Eligible amount  - Amount paid

Eligible amount1    :   1500           " this will fetched from Z table 
amount paid1        :                      " manully entered by user --> then saved to z table
Balance amount1  :   1500           " Eligible amount  - Amount paid

Please advice,

R.Karthik

1 ACCEPTED SOLUTION
Read only

faisalatsap
Active Contributor
0 Likes
1,683

Hi, Karthik

Sorry, i am not clear with the Requirement can you please explain it more clear way, and past your code if possible.

Thanks and Regards,

Faisal

12 REPLIES 12
Read only

Former Member
0 Likes
1,683

what is the problem?

you need code for this??

Read only

0 Likes
1,683

Yes, else please give some idea !!

Read only

faisalatsap
Active Contributor
0 Likes
1,684

Hi, Karthik

Sorry, i am not clear with the Requirement can you please explain it more clear way, and past your code if possible.

Thanks and Regards,

Faisal

Read only

0 Likes
1,683

Hi Faisal,

I am pasting my a pinch of my code :

AT SELECTION-SCREEN.

  CLEAR: ZSCHOOL.

  SELECT * FROM ZABC INTO CORRESPONDING FIELDS OF TABLE ITAB
                                    WHERE PERNR EQ S_PERNR.

  SELECT SINGLE * FROM PA0001 WHERE PERNR EQ S_PERNR
                                 AND  ENAME NE ' '.

  MOVE PA0001-ENAME TO S_NAME.

  CLEAR: NAME3,GBDAT3,NEWAMT3,PAID3.
  LOOP AT ITAB.

    IF SY-TABIX EQ 1.

      MOVE ITAB-NAME TO NAME1.
      MOVE ITAB-GBDAT TO GBDAT1.
      MOVE ITAB-NEWAMT TO NEWAMT1.
      MOVE ITAB-ELGI TO ELGI1.
      MOVE ITAB-PAID TO PAID1.

    ELSEIF SY-TABIX EQ 2.

      MOVE ITAB-NAME TO NAME2.
      MOVE ITAB-GBDAT TO GBDAT2.
      MOVE ITAB-ELGI TO ELGI2.
      MOVE ITAB-NEWAMT TO NEWAMT2.
      MOVE ITAB-PAID TO PAID2.

    ELSEIF SY-TABIX EQ 3.

      MOVE ITAB-NAME TO NAME3.
      MOVE ITAB-GBDAT TO GBDAT3.
      MOVE ITAB-ELGI TO ELGI3.
      MOVE ITAB-NEWAMT TO NEWAMT3.
      MOVE ITAB-PAID TO PAID3.

    ENDIF. 

  ENDLOOP.

AT SELECTION-SCREEN OUTPUT.

  LOOP AT SCREEN.

    IF SCREEN-GROUP1 = 'TH1'.
      SCREEN-INPUT = '1'.
    ENDIF.
    MODIFY SCREEN.
  ENDLOOP.

  LOOP AT SCREEN.

    IF SCREEN-GROUP1 = 'TH2'.
      SCREEN-INPUT = '1'.
    ENDIF.
    MODIFY SCREEN.
  ENDLOOP.

  LOOP AT SCREEN.

    IF SCREEN-GROUP1 = 'TH3'.
      SCREEN-INPUT = '1'.
    ENDIF.
    MODIFY SCREEN.
  ENDLOOP.

  LOOP AT SCREEN.

    IF SCREEN-GROUP1 = 'TH4'.
      SCREEN-INPUT = '1'.
    ENDIF.
    MODIFY SCREEN.
  ENDLOOP.

Please advice

Karthik

Read only

0 Likes
1,683

Hi, Karthik

Sorry, Still your requirement is not clear can you Please explain, i think no one will understand what exactly you want.

Please Reply with more explanation.

Regards,

Faisal

Read only

0 Likes
1,683

PUT all your code in at selection-screen ouput.

check the sy-ucomm,

and pass values accordingly.

your code looks fine.

Read only

0 Likes
1,683

Hi,

Use this code... this will surely help you... Have just modified certain lines....



DATA : w_flag TYPE c.

AT SELECTION-SCREEN.
 
  CLEAR: ZSCHOOL.
 
  SELECT * FROM ZABC INTO CORRESPONDING FIELDS OF TABLE ITAB
                                    WHERE PERNR EQ S_PERNR.
 
  IF SY-SUBRC = 0.                    "  Added Code
    W_FLAG = 'X'
  ENDIF.

  SELECT SINGLE * FROM PA0001 WHERE PERNR EQ S_PERNR
                                 AND  ENAME NE ' '.
 
  MOVE PA0001-ENAME TO S_NAME.
 
  CLEAR: NAME3,GBDAT3,NEWAMT3,PAID3.
  LOOP AT ITAB.
 
    IF SY-TABIX EQ 1.            
 
      MOVE ITAB-NAME TO NAME1.
      MOVE ITAB-GBDAT TO GBDAT1.
      MOVE ITAB-NEWAMT TO NEWAMT1.
      MOVE ITAB-ELGI TO ELGI1.
      MOVE ITAB-PAID TO PAID1.
 
    ELSEIF SY-TABIX EQ 2.
 
      MOVE ITAB-NAME TO NAME2.
      MOVE ITAB-GBDAT TO GBDAT2.
      MOVE ITAB-ELGI TO ELGI2.
      MOVE ITAB-NEWAMT TO NEWAMT2.
      MOVE ITAB-PAID TO PAID2.
 
    ELSEIF SY-TABIX EQ 3.
 
      MOVE ITAB-NAME TO NAME3.
      MOVE ITAB-GBDAT TO GBDAT3.
      MOVE ITAB-ELGI TO ELGI3.
      MOVE ITAB-NEWAMT TO NEWAMT3.
      MOVE ITAB-PAID TO PAID3.
 
    ENDIF. 
 
  ENDLOOP.
 
AT SELECTION-SCREEN OUTPUT.
 
IF W_FLAG = 'X'.           " Added Code 
  LOOP AT SCREEN.
 
    IF SCREEN-GROUP1 = 'TH1'.
      SCREEN-INPUT = '1'.
    ENDIF.
     
    ELSEIF SCREEN-GROUP1 = 'TH2'.         " Modified
      SCREEN-INPUT = '1'.
    ENDIF.
 
    ELSEIF SCREEN-GROUP1 = 'TH3'.         " Modified
      SCREEN-INPUT = '1'.
    ENDIF.
  
    ELSEIF SCREEN-GROUP1 = 'TH4'.         " Modified
      SCREEN-INPUT = '1'.
    ENDIF.
    MODIFY SCREEN.
  ENDLOOP.

ENDIF.

Regards,

Siddarth

Read only

0 Likes
1,683

Hi Sidhu,

Thanks a lot !!

I have not checked ur code yet, but I need some more clarification.

My actual requirement is :

When the user enters personal Number and executes all the other

information should display in the same screen except the PAID AMOUNT ( as it is manualy entered )

When User enters Paid amount and click a button , calculation should happen

i.e Balance amount = Eligible amount - Paid Amount. Then User click Save button

then the details will go and save in Z table...

My problem is when next time when the user enters the Personal Number and executes it

the previous Balance amount should be the Eligible amount this time...like wise till

the eligible amount become '0'.

Please advice if I need to create another Z table for this

Karthik

Edited by: Karthik R on Aug 22, 2009 12:33 PM

Read only

0 Likes
1,683

Hi Faisal,

I have explianed my requirement above, please advice me if u have any idea.

Thanks

Karthik

Read only

0 Likes
1,683

Hi,

No need to create another ztable. You add the paid amount, balance amount and eligible amount fields to the ztable. You do the necessary calculations and update the ztable using MODIFY statement. Now you can use the balance amount as the eligible amount when you execute next time.

Thanks,

Sri.

Read only

0 Likes
1,683

Hi, Karthik

Following is my Sample Table Definition You need to create a table like to following one with name ZTEST to test the bellow Sample Code.

MANDT	MANDT	CLNT	3	0	Client
PERNR	PERSNO	NUMC	8	0	Personnel number
EA		DEC	10	0	Eligible amount
BA		DEC	10	0	Balance Amount
PA		DEC	10	0	Paid Amount 

Sample Program

REPORT  zfsl_sdn_test.
TABLES: ztest.
DATA: it_ztest LIKE STANDARD TABLE OF ztest WITH HEADER LINE.

PARAMETERS: ppernr LIKE ztest-pernr,
            pea    LIKE ztest-ea MODIF ID cha,
            ppa    LIKE ztest-pa.
SELECTION-SCREEN PUSHBUTTON:  54(24) bt1_save   USER-COMMAND sav VISIBLE LENGTH 3.
PARAMETERS: pba    LIKE ztest-ba MODIF ID cha.

INITIALIZATION.
  CALL FUNCTION 'ICON_CREATE'
    EXPORTING
      name                  = 'ICON_SYSTEM_SAVE'
      add_stdinf            = 'X'
    IMPORTING
      RESULT                = bt1_save.

AT SELECTION-SCREEN.

  IF pea IS INITIAL.
    SELECT * FROM ztest INTO CORRESPONDING FIELDS OF ztest WHERE pernr = ppernr. ENDSELECT.
    IF sy-subrc = 0.
      pea = ztest-ea.
      pba = ztest-ba.
    ENDIF.
  ENDIF.

  IF sy-ucomm = 'SAV'.
    IF ppa IS NOT INITIAL.
      ztest-ba = ztest-ba - ppa.
      ztest-ea = ztest-ba.
      IF ztest-ba >= 0 OR ztest-ea >= 0.
        MODIFY ztest FROM ztest.
        pba = ztest-ba.
      ELSE.
        MESSAGE 'Some Amount Less than Zero' TYPE 'I'.
      ENDIF.
    ENDIF.
  ENDIF.

AT SELECTION-SCREEN OUTPUT.
  LOOP AT SCREEN.
    IF screen-group1 = 'CHA'.
      screen-input = 0.
    ENDIF.
    MODIFY SCREEN.
  ENDLOOP.

Please Reply in case of any Confusion you just need to place some records in DB Table and these the program giving that Personal Numbers.

Hope will help you to solve out your problem,

Best Regards,

Faisal

Read only

0 Likes
1,683

Hi Faisal,

Thank U !!