SAP R/3 форум ABAP консультантов
Russian ABAP Developer's Club

Home - FAQ - Search - Memberlist - Usergroups - Profile - Log in to check your private messages - Register - Log in - English
Blogs - Weblogs News

Push button "Select Block" on the list



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> List Generation, LDB, Spool Process, SAP Query, Report Painter
View previous topic :: View next topic  
Author Message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1640

PostPosted: Sat Oct 06, 2007 11:34 pm    Post subject: Push button "Select Block" on the list Reply with quote

There is a plain report (Use read data & write output, not ALV).
And there is a checkbox(itab-chx) before each line of the output list.

The customer wants me to add 4 buttons on the menu bar, they are 'Delete', 'Select ALL', 'Deselect all', 'Select block'.

Code:

REPORT zSelectBlock.
*---------------------------

data : begin of itab occurs 0,
chk type c,
v(25) type c,
end of itab.
data : c type c.
data : h(10) type c.
data : reccount type i.
data : ctr type i.

*---------------------------
itab-v = 'AAAAAA'.
append itab.
itab-v = 'BBBBBB'.
append itab.
itab-v = 'CCCCCC'.
append itab.
itab-v = 'DDDDDD'.
append itab.
itab-v = 'EEEEE'.
append itab.

*---------------------------
loop at itab.
write :/ c as checkbox , itab-v.

endloop.
*---------------------------


There is a general logic of 'Select block' using line selection function not using checkbox. How to intergrate it into above program. Surely i know those things like 'PF-status' define things...Just dont know what the logic should be after 'case user command' and handling with Checkbox in Internal table.

Code:

DATA: INDEX0_ITAB LIKE SY-TFILL,
INDEX1_ITAB LIKE SY-TFILL,
INDEX2_ITAB LIKE SY-TFILL.
*&---------------------------------------------------------------------*
*& Module USER_COMMAND INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE USER_COMMAND INPUT.

CASE OK_CODE.

WHEN 'SBLK'.
CLEAR OK.
CLEAR SY-UCOMM.
PERFORM SELECT_BLOCK.

ENDCASE.
*&---------------------------------------------------------------------*
*& Form SELECT_BLOCK
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM SELECT_BLOCK.

DATA: INDEX0_ITAB LIKE SY-TFILL.
DESCRIBE TABLE ITAB LINES SY-TFILL.
CHECK: SY-TFILL GT 0.
INDEX0_ITAB = 1.
WHILE INDEX0_ITAB LE SY-TFILL.
INDEX1_ITAB = INDEX0_ITAB.
READ TABLE ITAB INDEX INDEX1_ITAB.
WHILE ITAB-SEL EQ ' ' AND
INDEX1_ITAB LE SY-TFILL.
INDEX1_ITAB = INDEX1_ITAB + 1.
READ TABLE ITAB INDEX INDEX1_ITAB.
ENDWHILE.
INDEX2_ITAB = INDEX1_ITAB + 1.
READ TABLE ITAB INDEX INDEX2_ITAB.
WHILE ITAB-SEL EQ ' ' AND
INDEX2_ITAB LE SY-TFILL.
INDEX2_ITAB = INDEX2_ITAB + 1.
READ TABLE ITAB INDEX INDEX2_ITAB.
ENDWHILE.
INDEX0_ITAB = INDEX2_ITAB + 1.
LOOP AT ITAB FROM INDEX1_ITAB TO INDEX2_ITAB.
ITAB-SEL = 'X'.
MODIFY ITAB.
ENDLOOP.
ENDWHILE.
ENDFORM. " SELECT_BLOCK


Code:
Example 2

Code:

*Eject
**********************************************************************
*
*       Procedure:             Select_All
*
*       Purpose:               Selects all operations for all orders
*
*       Entry:
*
*       Exit:
*
*       Called By:             Perform Select_All.
*
*       Calls:
*
*       Modification History:
*
Form Select_All.
     Perform Sel_Desel using True.
EndForm.
*Eject
**********************************************************************
*
*       Procedure:             Select_Single
*
*       Purpose:               Selects all operations for current line
*
*       Entry:                 sy-lilli contains line to change.
*
*       Exit:
*
*       Called By:             Perform Select_Single using True
*                                                          w_opts
*
*       Calls:
*
*       Modification History:
*
Form Select_Single using p_value type boolean
                         p_opts  type operations.
     If p_opts-cnfmd = True.
        Modify Line sy-lilli
                    Field Value g_report_line-cnfmd from p_value.
     EndIf.
     If p_opts-recpt = True.
        Modify Line sy-lilli
                    Field Value g_report_line-recpt from p_value.
     EndIf.
     If p_opts-pickd = True.
        Modify Line sy-lilli
                    Field Value g_report_line-pickd from p_value.
     EndIf.
EndForm.
*Eject
**********************************************************************
*
*       Procedure:             Sel_Desel
*
*       Purpose:               Selects/deselects all operations for
*                              all orders
*
*       Entry:                 True - select orders, false otherwise
*
*       Exit:
*
*       Called By:             Perform Sel_Desel using True.
*
*       Calls:
*
*       Modification History:
*
Form Sel_Desel using p_value type boolean.
*
*    Get the operations to select/deselect
*
     If p_value = True.
        Call Selection-Screen 3000 starting at 10 10 ending at 60 20.
     Else.
        Call Selection-Screen 4000 starting at 10 10 ending at 60 20.
     EndIf.
     If g_cancel = false.
        Do.
            Clear g_report_line.
            Read Line sy-index Field Value g_report_line-vbeln.
            If sy-subrc <> 0.
               Exit.
            Else.
               If g_report_line-vbeln <> ''.
                  Move sy-index to sy-lilli.
                  Perform Select_Single using p_value g_opts.
               Endif.
            EndIf.
        EndDo.
     EndIf.
EndForm.
*Eject
**********************************************************************
*
*       Procedure:             DeSelect_All
*
*       Purpose:               DeSelects all operations for all orders
*
*       Entry:
*
*       Exit:
*
*       Called By:             Perform DeSelect_All.
*
*       Calls:
*
*       Modification History:
*
Form DeSelect_All.
     Perform Sel_Desel using False.
EndForm.
*Exit
**********************************************************************
*
*       Procedure:            Select_Block
*
*       Purpose:              Selects/deselects a block of lines for
*                             processing
*
*       Entry:                Toggle value
*
*       Exit:
*
*       Called By:            Perform Select_All usign true.
*
*       Calls:
*
*       Modification History:
*
*   Date    Reason                                       Version  Who
*
Form Select_Block.
*
     Statics w_first_line  like sy-lilli.

     Data: w_second_line   like sy-lilli,
           w_saved         like sy-lilli,
           w_vbeln         like lips-vbeln.
*
*    Is the first line set ?
*
     If w_first_line = 0.
*
*       Nope,  save it...
*
        Read Line Sy-Lilli field value g_report_line-vbeln into w_vbeln.
        If w_vbeln <> ''.
           Move sy-lilli to w_first_line.
           Modify Line sy-lilli Line format Inverse on.
        Else.
           Message I000 with text-020.
        EndIf.
     Else.
*
*       Make sure that the first line is before the second.
*
        Move sy-lilli to w_saved.
        Read Line w_first_line
             field value g_report_line-vbeln into w_vbeln.
        If w_vbeln <> ''.
           Modify Line w_first_line Line format Inverse off.
           If w_first_line > w_saved.
              Move w_first_line to w_second_line.
              Move w_saved to w_first_line.
           Else.
              Move w_saved to w_second_line.
           EndIf.
*
*          Get the operations to select
*
           Call Selection-Screen 3000 starting at 10 10 ending at 60 20.
           If g_cancel = False.
              Do.
                  If w_first_line > w_second_line.
                     Exit.
                  Else.
                     Move '' to w_vbeln.
                     Read Line w_first_line
                         field value g_report_line-vbeln into w_vbeln.
                     If w_vbeln <> ''.
                        Move w_first_line to sy-lilli.
                        Perform select_single using True g_opts.
                     EndIf.
                     Add 1 to w_first_line.
                  EndIf.
              EndDo.
           EndIf.
           Move 0 to w_first_line.
           Move 0 to w_second_line.
        Else.
           Message I000 with text-010.
        EndIf.
     EndIf.
EndForm.

This does not touch the table that the report is derived from, but just changes the fields on the report.

Then when you want to do something with those rows (such as your delete):

Code:

*
*       Locate the lines on the report to process.
*
        Describe List Number Of Lines w_Max.
        Do.
            Move sy-index to w_current.
            Clear g_report_line.
            Read Line w_current Field Value g_report_line-vbeln
                                            g_report_line-posnr
                                            g_report_line-cnfmd
                                            g_report_line-recpt
                                            g_report_line-pickd.
            If sy-subrc <> 0.
               Exit.
            Else.
*
*              Find the order line in the order table.
*
               If g_report_line-vbeln <> ''.
                  Call Function 'CONVERSION_EXIT_ALPHA_INPUT'
                       Exporting
                            Input   = g_report_line-vbeln
                       Importing
                            Output  = g_report_line-vbeln
                       Exceptions
                            Others  = 1.
                  Read Table t_order_list into w_order_line
                       with key Lvbln = g_report_line-vbeln
                                Lpsnr = g_report_line-posnr.
*
*                 What do we need to do ?
*
                  If g_report_line-cnfmd = True.
                     AddDiscrete w_order_line-vbeln r_cnfmd.
                  EndIf.
                  If g_report_line-recpt = True.
                     AddDiscrete w_order_line-vbeln r_recpt.
                  EndIf.
                  If g_report_line-pickd = True.
                     AddDiscrete w_order_line-vbeln r_pickd.
                  EndIf.
               EndIf.
            EndIf.
            Perform Show_Progress using Text-023 w_max w_current 0.
        EndDo.

Note that you need to put any fields that require a user exit through the relevant user exit before you use it's value.

These should all be called from the USER-COMMAND event.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> List Generation, LDB, Spool Process, SAP Query, Report Painter All times are GMT + 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG.
SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG.
Every effort is made to ensure content integrity. Use information on this site at your own risk.