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

SAP ALV Tutorial 1 – Layout



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> ALV Grid / ALV Tree / ALV List
View previous topic :: View next topic  
Author Message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1636

PostPosted: Wed Dec 15, 2010 12:48 pm    Post subject: SAP ALV Tutorial 1 – Layout Reply with quote

Source from: ALV Layout

The layout stands for a set of settings about sort, total and which fields need to be displayed. It is a common case that different user needs to have different layout of the alv. SAP has provide functionality to user to create, change, save or even transport the layout to the subsequent systems.


SAP alv Layout Common functionality
1. Choose Layout.

To choose an existing layout for the display of the list, choose Choose layout or Settings ® Display layout ® Choose. You can change the layout of ALV using the following ALV funcitons:
a. Sort order
b. Set Filter or delete Filter
c. Change layout
d. Find…

In the dialog box, choose a layout either by clicking the layout name or by positioning the cursor on the relevant layout and choosing Copy.

2. Save Layout.
Choose Save layout or Settings->Layout->Save. In the dialog box, enter a name and a description for your layout.
You cannot gives the layout a name with number, since this type of name is reserved for the standard layouts in the standard system. In general, layouts are available for all users as client-specific standard layouts, but you can select User-specific option which means that this layout only avaliable for current user.

Naming conversion of layout. User-specific layouts must begin with a letter (A-Z). Non-user-specific layouts(client-specific standard layouts) must begin of with “/”.

3. Layout management.
To call layout management, choose Settings->Layout->Management. We can delete a layout or set a layout as default.

We can also import or transport layout using layout management. The layout will not be added to a transport when you create it, but you can add it to a transport manually using layout management.

SAP ALV Layout programming

Some requirements need to allow user to choose a specific layout in the report selection screen. This means that we need to add some additional codes to achieve that. There several FM for this purpose.

REUSE_ALV_VARIANT_DEFAULT_GET - get the default layout of this report
REUSE_ALV_VARIANT_EXISTENCE - check whether the input layout name exists
REUSE_ALV_VARIANT_F4 - pop up a screen to allow user to choose existing layout

Below are several steps to use these FM.

Step 1. Define layout data.

Code:
DATA: GS_VARIANT LIKE DISVARIANT. ” define the data representation of a layout
               V_EXIT.


Step 2. Define selection screen.

Code:
SELECTION-SCREEN BEGIN OF BLOCK B3 WITH FRAME TITLE TEXT-003.

PARAMETERS: P_VARI LIKE DISVARIANT-VARIANT. ” define a parameter using type DISVARIANT-VARIANT

SELECTION-SCREEN END OF BLOCK B3.


Step 3. Define event “AT SELECTION-SCREEN ON VALUE-REQUEST FOR …”.

Code:
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_VARI.
GS_VARIANT-REPORT = SY-REPID. ” set the report name to the current report.

CALL FUNCTION ‘REUSE_ALV_VARIANT_F4′ “call layout selection screen
  EXPORTING
     IS_VARIANT = GS_VARIANT
     I_SAVE = ‘A’
  IMPORTING
     E_EXIT = V_EXIT
     ES_VARIANT = GS_VARIANT
  EXCEPTIONS
     NOT_FOUND = 2.

IF SY-SUBRC = 2.

MESSAGE ID SY-MSGID TYPE ‘S’ NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ELSE.

IF V_EXIT = SPACE.

P_VARI = GS_VARIANT-VARIANT.

ENDIF.

ENDIF.


Step 4. Define event ‘Initialization’ to get the default layout.

Code:
GS_VARIANT-REPORT = SY-REPID.

CALL FUNCTION ‘REUSE_ALV_VARIANT_DEFAULT_GET’
  EXPORTING
     I_SAVE = ‘A’
  CHANGING
     CS_VARIANT = GS_VARIANT
  EXCEPTIONS
     WRONG_INPUT = 1
     NOT_FOUND = 2
     PROGRAM_ERROR = 3
    OTHERS = 4.

IF SY-SUBRC EQ 0.

P_VARI = GS_VARIANT-VARIANT.

ENDIF.


Step 5. Pass the selected layout to the ‘REUSE_ALV_GRID_DISPLAY’.

We need to pass the selected layout to parameter named ‘IS_VARIANT’. At the same time we need to pass a value to paramenter named ‘I_SAVE’. I_SAVE has a type of c and several value can be passed into it.

‘ ‘ = display variants cannot be saved

Defined display variants (e.g. delivered display variants) can be selected for presentation independently of this flag. Changes can not be saved.

‘X’ = standard save

Display variants can be saved as standard display variants. User-specific saving is not possible.

‘U’ = only user-specific saving

The user can only save display variants user-specifically

‘A’ = standard and user-specific saving

The user can save a display variant user-specifically and as standard display variant. The user chooses in the display variant save popup.
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 -> ALV Grid / ALV Tree / ALV List 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.