Application Development 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: 

Problem with Dispaly data

Former Member
0 Kudos

Hi,

I have to select records based on date range, if I press 'SELE' button it is working fine and selecting records in the date range. But if I press again it has to deselect the selected records, this is not happening.

In gs_zchbox Chbox is not showing as 'X' in deselect, Am I doing anything wrong. And also the smae output is displaying the number of times(3 times) I press SELE button(3 times). what should I do for proper SELECT/DESELECT button and updated display.

Thanks,

Veni.

1 ACCEPTED SOLUTION

ferry_lianto
Active Contributor
0 Kudos

Hi,

Please try this.


 WHEN 'SELE'.
   SET PF-STATUS 'STAT'.
   NEW-PAGE LINE-SIZE 179.
 
   r_date-low = sy-datum - 3.
   r_date-high = sy-datum + 3.
   r_date-option = 'BT'.
   r_date-sign = 'I'.
   APPEND r_date.
 
   IF gs_zchbox[] is initial.
     LOOP AT gt_zprice INTO gs_zchbox.
       IF gs_zchbox-crdate >= r_date-low AND
          gs_zchbox-crdate <= r_date-high.
         gs_zchbox-chbox = 'X'.
         APPEND gs_zchbox TO gt_zchbox.
         CLEAR gs_zchbox.
       ENDIF.
     ENDLOOP.
   ELSE.
     LOOP AT gs_zchbox INTO gs_zchbox.
       IF gs_zchbox-crdate >= r_date-low AND
          gs_zchbox-crdate <= r_date-high.
         IF gs_zchbox-chbox = 'X'.
           gs_zchbox-chbox = ' '.
         ELSE.
           gs_zchbox-chbox = 'X'.
         ENDIF.
         MODIFY gs_zchbox FROM gt_zchbox TRANSPORTING chbox.
         CLEAR gs_zchbox.
       ENDIF.
     ENDLOOP.
   ENDIF.

   WRITE: /01(179) sy-uline.
   PERFORM headings.
   WRITE: /01(179) sy-uline.
   PERFORM displaydata2.

Regards,

Ferry Lianto

20 REPLIES 20

Former Member
0 Kudos

Hi,

Here is a suggestion - you can set a flag F_SELECT = 'X' when user first clicks on button. Now if the flag is set, handle processing for action SELECT.

IF user again clicks on SELECT, reset flag which will indicate that it is now deselected and again for Flag = space you can handle deselect action.

Hope this helps.

ashish

ferry_lianto
Active Contributor
0 Kudos

Hi,

Usually, you need to have two buttons for Select and Deselect purposes.

If you only want to have a single button for dual roles then you can do as Ashish suggested to use a flag. When the Select button press for the first time, set flag = "X' and perform select records. When the Select button press for second time, you can check the flag value. If flag = "X' then perform deselect selected records and initialize the flag at the end.

Regards,

Ferry Lianto

0 Kudos

Hi Ashish and Ferry,

The Deselect is not at all working and if I click on 'sele' button 2 times the display data also executing 2 times and output is comming 2 times. Please help me figure out what I am doing wrong here.

Thanks,

Veni.


    WHEN 'SELE'.
      SET PF-STATUS 'STAT'.
      NEW-PAGE LINE-SIZE 179.

      r_date-low = sy-datum - 3.
      r_date-high = sy-datum + 3.
      r_date-option = 'BT'.
      r_date-sign = 'I'.
      APPEND r_date.

      LOOP AT gt_zprice INTO gs_zchbox.
      
        IF gs_zchbox-chbox = 'X'.
          gs_zchbox-chbox = ' '.
          
        ELSEIF gs_zchbox-chbox = ' '.
          IF gs_zchbox-crdate >= r_date-low
                AND gs_zchbox-crdate <= r_date-high.
            gs_zchbox-chbox = 'X'.
*          ELSE.
*            gs_zchbox-chbox = ' '.
          ENDIF.
        ENDIF.
        
        APPEND gs_zchbox TO gt_zchbox.
        CLEAR gs_zchbox.
      ENDLOOP.

      WRITE: /01(179) sy-uline.
      PERFORM headings.
      WRITE: /01(179) sy-uline.
      PERFORM displaydata2.

0 Kudos

Hi,

I think you are not refreshing contents of internal table gt_zchbox which is causing the problem. Refresh the table and check again and make sure that all variables and internal tables are refreshed and cleared with each action.

ashish

0 Kudos

Hi Ashish,

I added refresh after display data. Now the display is comming only once, but deselect is still not working. Selecting is working properly in the date range.

Please help me with the problem.

Thanks,

Veni.


    WHEN 'SELE'.
      SET PF-STATUS 'STAT'.
      NEW-PAGE LINE-SIZE 179.

      r_date-low = sy-datum - 3.
      r_date-high = sy-datum + 3.
      r_date-option = 'BT'.
      r_date-sign = 'I'.
      APPEND r_date.

      LOOP AT gt_zprice INTO gs_zchbox.
        IF gs_zchbox-chbox = 'X'.
          gs_zchbox-chbox = ' '.
        ELSEIF gs_zchbox-chbox = ' '.
          IF gs_zchbox-crdate >= r_date-low
                AND gs_zchbox-crdate <= r_date-high.
            gs_zchbox-chbox = 'X'.
*          ELSE.
*            gs_zchbox-chbox = ' '.
          ENDIF.
        ENDIF.
        APPEND gs_zchbox TO gt_zchbox.
        CLEAR gs_zchbox.
      ENDLOOP.

      WRITE: /01(179) sy-uline.
      PERFORM headings.
      WRITE: /01(179) sy-uline.
      PERFORM displaydata2.
        REFRESH gt_zchbox.

0 Kudos

Hi,

Can you debug the code once and see what happens in second action? Please let us know the findings.

ashish

0 Kudos

Hi Ferry,

I tried the code and it is giving me the short dump, on modify. And the display is containing only the records in the date range selected not all records with checked date range records. Deselect is giving short dump. Please help me with the problem.

Thanks,

Veni.

You attempted to change, delete or create a line in the

internal table "\PROG=ZSD_CREDITMEMO\DATA=GT_ZCHBOX[]", but no valid cursor

exists

for the table.

Possible reasons:

1. The relevant ABAP/4 statement does not include the addition

"...INDEX...", although the statement is not

inside a "LOOP...ENDLOOP" loop processing this table.

2. The relevant ABAP/4 statement was called from within a

"LOOP...ENDLOOP" loop after a DELETE

"\PROG=ZSD_CREDITMEMO\DATA=GT_ZCHBOX[]".


    WHEN 'SELE'.
      SET PF-STATUS 'STAT'.
      NEW-PAGE LINE-SIZE 179.

      r_date-low = sy-datum - 3.
      r_date-high = sy-datum + 3.
      r_date-option = 'BT'.
      r_date-sign = 'I'.
      APPEND r_date.

      IF gs_zchbox IS INITIAL.
        LOOP AT gt_zprice INTO gs_zchbox.
          IF gs_zchbox-crdate >= r_date-low AND
             gs_zchbox-crdate <= r_date-high.
            gs_zchbox-chbox = 'X'.
            APPEND gs_zchbox TO gt_zchbox.
            CLEAR gs_zchbox.
          ENDIF.
        ENDLOOP.
      ELSE.
        LOOP AT gt_zprice INTO gs_zchbox.
          IF gs_zchbox-crdate >= r_date-low AND
             gs_zchbox-crdate <= r_date-high.
            gs_zchbox-chbox = ' '.
*            APPEND gs_zchbox TO gt_zchbox.
            MODIFY gt_zchbox FROM gs_zchbox TRANSPORTING chbox.
            CLEAR gs_zchbox.
          ENDIF.
        ENDLOOP.
      ENDIF.

      WRITE: /01(179) sy-uline.
      PERFORM headings.
      WRITE: /01(179) sy-uline.
      PERFORM displaydata2.

0 Kudos

Hi Ashish and Ferry,

This following code worked with Append stmt instead of Modify stmt for both Select and Deselect options, only problem now is instead of all records(40) it is displaying the records with in the date range(12). Please guide me.

Thanks,

Veni.


 WHEN 'SELE'.
      SET PF-STATUS 'STAT'.
      NEW-PAGE LINE-SIZE 179.

      r_date-low = sy-datum - 3.
      r_date-high = sy-datum + 3.
      r_date-option = 'BT'.
      r_date-sign = 'I'.
      APPEND r_date.

      IF gs_zchbox IS INITIAL.
        LOOP AT gt_zprice INTO gs_zchbox.
          IF gs_zchbox-crdate >= r_date-low AND
             gs_zchbox-crdate <= r_date-high.
            gs_zchbox-chbox = 'X'.
            APPEND gs_zchbox TO gt_zchbox.
            CLEAR gs_zchbox.
          ENDIF.
        ENDLOOP.
      ELSE.
        LOOP AT gt_zprice INTO gs_zchbox.
          IF gs_zchbox-crdate >= r_date-low AND
             gs_zchbox-crdate <= r_date-high.
            gs_zchbox-chbox = ' '.
            APPEND gs_zchbox TO gt_zchbox.
*            MODIFY gt_zchbox FROM gs_zchbox TRANSPORTING chbox.
            CLEAR gs_zchbox.
          ENDIF.
        ENDLOOP.
      ENDIF.

      WRITE: /01(179) sy-uline.
      PERFORM headings.
      WRITE: /01(179) sy-uline.
      PERFORM displaydata2.
      REFRESH gt_zchbox.

0 Kudos

Hi,

Instead of using condition in following way -

IF gs_zchbox-crdate >= r_date-low AND

gs_zchbox-crdate <= r_date-high.

why don't you use this -

IF NOT GS_ZCHBOX-CRADATE IN R_DATE.

Also change other condition in this way.

Once you activate code, i suggest to run in debug mode for records which are not selected. Check the reason, some condition is failing which needs to be corrected.

ashish

0 Kudos

Hi,

Instead of using condition in following way -

IF gs_zchbox-crdate >= r_date-low AND

gs_zchbox-crdate <= r_date-high.

why don't you use this -

IF GS_ZCHBOX-CRADATE IN R_DATE.

Also change other condition in this way.

Once you activate code, i suggest to run in debug mode for records which are not selected. Check the reason, some condition is failing which needs to be corrected.

ashish

0 Kudos

Hi Ashish and Ferry,

This following code worked with out any problems. Can you please check if I am doing it properly.

I changed the following.

1)gt_zchbox[] = gt_zprice[].

2)LOOP AT gt_zchbox INTO gs_zchbox. looped on gt_zchbox instead of gt_price.

3) MODIFY gt_zchbox FROM gs_zchbox.

Thanks,

Veni.


    WHEN 'SELE'.
      SET PF-STATUS 'STAT'.
      NEW-PAGE LINE-SIZE 179.

      r_date-low = sy-datum - 3.
      r_date-high = sy-datum + 3.
      r_date-option = 'BT'.
      r_date-sign = 'I'.
      APPEND r_date.

gt_zchbox[] = gt_zprice[].

      IF gs_zchbox IS INITIAL.
        LOOP AT gt_zchbox INTO gs_zchbox.
          IF gs_zchbox-crdate >= r_date-low AND
             gs_zchbox-crdate <= r_date-high.
            gs_zchbox-chbox = 'X'.
*            APPEND gs_zchbox TO gt_zchbox.
            MODIFY gt_zchbox FROM gs_zchbox.
            CLEAR gs_zchbox.
          ENDIF.
        ENDLOOP.
      ELSE.
        LOOP AT gt_zchbox INTO gs_zchbox.
          IF gs_zchbox-crdate >= r_date-low AND
             gs_zchbox-crdate <= r_date-high.
            gs_zchbox-chbox = ' '.
*            APPEND gs_zchbox TO gt_zchbox.
            MODIFY gt_zchbox FROM gs_zchbox.
*            MODIFY gt_zchbox FROM gs_zchbox TRANSPORTING chbox.
            CLEAR gs_zchbox.
          ENDIF.
        ENDLOOP.
      ENDIF.

      WRITE: /01(179) sy-uline.
      PERFORM headings.
      WRITE: /01(179) sy-uline.
      PERFORM displaydata2.
      REFRESH gt_zchbox.

0 Kudos

Hi,

This looks good to me and is it working as per the requirements?

ashish

0 Kudos

Thank you Ashish and Ferry.

I really appriciate your help.

Regards,

Veni.

ferry_lianto
Active Contributor
0 Kudos

Hi,

Please try this.


 WHEN 'SELE'.
   SET PF-STATUS 'STAT'.
   NEW-PAGE LINE-SIZE 179.
 
   r_date-low = sy-datum - 3.
   r_date-high = sy-datum + 3.
   r_date-option = 'BT'.
   r_date-sign = 'I'.
   APPEND r_date.
 
   IF gs_zchbox[] is initial.
     LOOP AT gt_zprice INTO gs_zchbox.
       IF gs_zchbox-crdate >= r_date-low AND
          gs_zchbox-crdate <= r_date-high.
         gs_zchbox-chbox = 'X'.
         APPEND gs_zchbox TO gt_zchbox.
         CLEAR gs_zchbox.
       ENDIF.
     ENDLOOP.
   ELSE.
     LOOP AT gs_zchbox INTO gs_zchbox.
       IF gs_zchbox-crdate >= r_date-low AND
          gs_zchbox-crdate <= r_date-high.
         IF gs_zchbox-chbox = 'X'.
           gs_zchbox-chbox = ' '.
         ELSE.
           gs_zchbox-chbox = 'X'.
         ENDIF.
         MODIFY gs_zchbox FROM gt_zchbox TRANSPORTING chbox.
         CLEAR gs_zchbox.
       ENDIF.
     ENDLOOP.
   ENDIF.

   WRITE: /01(179) sy-uline.
   PERFORM headings.
   WRITE: /01(179) sy-uline.
   PERFORM displaydata2.

Regards,

Ferry Lianto

ferry_lianto
Active Contributor
0 Kudos

Hi,

Please try this again.


WHEN 'SELE'.
   SET PF-STATUS 'STAT'.
   NEW-PAGE LINE-SIZE 179.
 
   r_date-low = sy-datum - 3.
   r_date-high = sy-datum + 3.
   r_date-option = 'BT'.
   r_date-sign = 'I'.
   APPEND r_date.
 
   IF gs_zchbox[] is initial.
     LOOP AT gt_zprice INTO gs_zchbox.
       IF gs_zchbox-crdate >= r_date-low AND
          gs_zchbox-crdate <= r_date-high.
         gs_zchbox-chbox = 'X'.
       ENDIF.
       APPEND gs_zchbox TO gt_zchbox.
       CLEAR gs_zchbox.
     ENDLOOP.
   ELSE.
     LOOP AT gs_zchbox INTO gs_zchbox.
       IF gs_zchbox-crdate >= r_date-low AND
          gs_zchbox-crdate <= r_date-high.
         IF gs_zchbox-chbox = 'X'.
           gs_zchbox-chbox = ' '.
         ELSE.
           gs_zchbox-chbox = 'X'.
         ENDIF.
         MODIFY gs_zchbox FROM gt_zchbox INDEX sy-tabix.
         CLEAR gs_zchbox.
       ENDIF.
     ENDLOOP.
   ENDIF.
 
   WRITE: /01(179) sy-uline.
   PERFORM headings.
   WRITE: /01(179) sy-uline.
   PERFORM displaydata2.

Regards,

Ferry Lianto

ferry_lianto
Active Contributor
0 Kudos

Hi,

Are you sure your previous codes are working fine?

If you are then try to change this.


WHEN 'SELE'.
      SET PF-STATUS 'STAT'.
      NEW-PAGE LINE-SIZE 179.
 
      r_date-low = sy-datum - 3.
      r_date-high = sy-datum + 3.
      r_date-option = 'BT'.
      r_date-sign = 'I'.
      APPEND r_date.
 
      IF gs_zchbox[] IS INITIAL.
        LOOP AT gt_zprice INTO gs_zchbox.
          IF gs_zchbox-crdate >= r_date-low AND
             gs_zchbox-crdate <= r_date-high.
            gs_zchbox-chbox = 'X'.
          ENDIF.                         "Add here
          APPEND gs_zchbox TO gt_zchbox.
          CLEAR gs_zchbox.
*         ENDIF.                         "Commented here 
        ENDLOOP.
      ELSE.
        LOOP AT gt_zprice INTO gs_zchbox.
          IF gs_zchbox-crdate >= r_date-low AND
             gs_zchbox-crdate <= r_date-high.
            gs_zchbox-chbox = ' '.
            APPEND gs_zchbox TO gt_zchbox.
*            MODIFY gt_zchbox FROM gs_zchbox TRANSPORTING chbox.
            CLEAR gs_zchbox.
          ENDIF.
        ENDLOOP.
      ENDIF.
 
      WRITE: /01(179) sy-uline.
      PERFORM headings.
      WRITE: /01(179) sy-uline.
      PERFORM displaydata2.
      REFRESH gt_zchbox.

Regards,

Ferry Lianto

ferry_lianto
Active Contributor
0 Kudos

Hi,

It will not work ... please try my previous codes.


WHEN 'SELE'.
   SET PF-STATUS 'STAT'.
   NEW-PAGE LINE-SIZE 179.
 
   r_date-low = sy-datum - 3.
   r_date-high = sy-datum + 3.
   r_date-option = 'BT'.
   r_date-sign = 'I'.
   APPEND r_date.
 
   IF gs_zchbox[] is initial.
     LOOP AT gt_zprice INTO gs_zchbox.
       IF gs_zchbox-crdate >= r_date-low AND
          gs_zchbox-crdate <= r_date-high.
         gs_zchbox-chbox = 'X'.
       ENDIF.
       APPEND gs_zchbox TO gt_zchbox.
       CLEAR gs_zchbox.
     ENDLOOP.
   ELSE.
     LOOP AT gs_zchbox INTO gs_zchbox.
       IF gs_zchbox-crdate >= r_date-low AND
          gs_zchbox-crdate <= r_date-high.
         IF gs_zchbox-chbox = 'X'.
           gs_zchbox-chbox = ' '.
         ELSE.
           gs_zchbox-chbox = 'X'.
         ENDIF.
         MODIFY gs_zchbox FROM gt_zchbox INDEX sy-tabix.
         CLEAR gs_zchbox.
       ENDIF.
     ENDLOOP.
   ENDIF.
 
   WRITE: /01(179) sy-uline.
   PERFORM headings.
   WRITE: /01(179) sy-uline.
   PERFORM displaydata2.

Regards,

Ferry Lianto

0 Kudos

Hi Ferry,

This also worked. So I will keep the following code. Please let me know if it is good.

Thanks,

Veni.



DATA: gt_zprice TYPE TABLE OF zppprice  WITH HEADER LINE,
      gt_zchbox TYPE TABLE OF ty_zchbox WITH HEADER LINE,
      gs_zchbox TYPE ty_zchbox,
      gs_zprice TYPE zppprice.

WHEN 'SELE'.
   SET PF-STATUS 'STAT'.
   NEW-PAGE LINE-SIZE 179.

   r_date-low = sy-datum - 3.
   r_date-high = sy-datum + 3.
   r_date-option = 'BT'.
   r_date-sign = 'I'.
   APPEND r_date.

*   IF gs_zchbox[] is initial.
   IF gs_zchbox is initial.

     LOOP AT gt_zprice INTO gs_zchbox.
       IF gs_zchbox-crdate >= r_date-low AND
          gs_zchbox-crdate <= r_date-high.
         gs_zchbox-chbox = 'X'.
       ENDIF.
       APPEND gs_zchbox TO gt_zchbox.
       CLEAR gs_zchbox.
     ENDLOOP.
   ELSE.
*     LOOP AT gs_zchbox INTO gs_zchbox.
     LOOP AT gt_zchbox INTO gs_zchbox.

       IF gs_zchbox-crdate >= r_date-low AND
          gs_zchbox-crdate <= r_date-high.
         IF gs_zchbox-chbox = 'X'.
           gs_zchbox-chbox = ' '.
         ELSE.
           gs_zchbox-chbox = 'X'.
         ENDIF.
*         MODIFY gs_zchbox FROM gt_zchbox INDEX sy-tabix.
         MODIFY gt_zchbox FROM gs_zchbox INDEX sy-tabix.

         CLEAR gs_zchbox.
       ENDIF.
     ENDLOOP.
   ENDIF.

   WRITE: /01(179) sy-uline.
   PERFORM headings.
   WRITE: /01(179) sy-uline.
   PERFORM displaydata2.


ferry_lianto
Active Contributor
0 Kudos

Hi Veni,

I have small doubt on this line but it works well for you then your codes are fine.


...
 

*  IF gs_zchbox[] is initial.
*  IF gs_zchbox is initial.            

* It should be this, isn't it? gs_zchbox is work area and gt_zchbox is an internal table
   IF gt_zchbox[]  is initial.
  ...

Regards,

Ferry Lianto

0 Kudos

Hi Ferry,

You are right. I changed it to, 'IF gt_zchbox[] is initial' and worked good.

I really appriciate your help.

Regards,

Veni.