Saturday, March 10, 2018

Views in SAP ABAP - Database View

View : A view acts just like a normal table only , but it will not occupy storage space in database layer. We can say that view is nothing but a virtual table (Physically not available but logically available).

View Types :

1. Database View
2.Projection View
3. Maintenance View
4.Help View


Database View :
--------------------

A Database view is used to join two or more basis tables. We can create Database view with single basis table also but it does not make any sense , in that case we can go for Projection View.

If they are multiple basis tables, they are joined using Inner Join.A matching SQL view will get create in DB Layer when we activate our view.

View Creation is just like Table creation only .

GOTO --> SE11

Select View radio Button --> Provide View name --> Select the View Type from POPUP

Important Points to remember : 
------------------------------------

1. We can use a basis table ( a transparent table) which is not active in DDIC for View Creation.

2 . If you didn't specify any join condition , then FullJoin will applied automatically.

3.If the database contains only one basis table , then you can change DB Table data using view.

For Ex : View name : ZNKP_DBVIEW.
              workaraea :  WA_VIEW refer to view .
             DB table : ZPLAYER.
         
             Modify ZNKP_DBVIEW from WA_VIEW.

ZPLAYER contents will get modified.


4.it's mandatory to maintain all key fields in View creation if you want use READ & CHANGE maintenance status . (This maintenance status will allow for single table only)

5.If you are using multiple tables , View is write protected.



Sunday, December 31, 2017

How to Change ALV Standard toolbar button text in SAP ABAP

Scenario : As per the requirement we need to display SAP ALV standard tool bar export button text as 'SAVE EXCEL' .By default the button text is 'Export'.

Solution :

All ALV standard toolbar buttons (Function Codes ) are available in SAP standard internal table

e_object->mt_toolbar.

here e_object is the one of the importing parameter of ALV TOOLBAR Event ( Toolbar Event : where we add customizing buttons to the ALV standard toolbar using the same internal table).

Customizing the standard text display :

In side the ALV Toolbar event handler , write the below mentioned piece of code .

LOOP AT e_object->mt_toolbar ASSIGNG <fieldsymbol>.

   IF <fieldsymbol>-function EQ '&MB_EXPORT' .  " (&MB_EXPORT is the FCODE of export                                                                                                button)
 
   <fieldsymbol>-text  = 'SAVE EXCEL' .   "User's customizing text

 ENDIF.
ENDLOOP.


Sunday, December 10, 2017

How to Increase length of Selection Texts ( Parameter/Select-options ) display text in sap ABAP


Limitation :

 If you declare any Selection screen elements (Parameter or Select - options ) , Corresponding displaying we will provide it in Selection texts.

Path -- GOTO --> Text Elements --> Selection Texts.

Ex :  SELECTION-SCREEN BEGIN OF BLOCK b1.
        PARAMETERS : p_rad1 RADIO BUTTON GROUP g1,
                                     p_rad2  RADIO BUTTON GROUP g1.

       SELECTION-SCREEN BEGIN OF BLOCK b1.

Here corresponding Display text of Radio buttons will provide in Selection Texts.But the Maximum length we can provide is 30.

But here in my requirement i need to provide display text as 40 for p_rad1 Radio Button . By using Selection texts , it's not possible.

Solution : 

       SELECTION-SCREEN BEGIN OF BLOCK b1.
       SELECTION-SCREEN BEGIN OF LINE.
       PARAMETERS : p_rad1 RADIO BUTTON GROUP g1.
       SELECTION-SCREEN COMMENT (50) text-001 FOR FIELD p_rad1.
       SELECTION-SCREEN END OF LINE.
       PARAMETERS :   p_rad2  RADIO BUTTON GROUP g1.
       SELECTION-SCREEN BEGIN OF BLOCK b1.


Maintain display text for text-001.

Path : GOTO-->Text Elements --> Text Symbols.

Wednesday, November 29, 2017

How to Remove/Delete or Hide CLOSE ( X ) Button in Model Dialog Box

Problem : How to Remove/Delete or Hide CLOSE ( X ) Button in Model Dialog Box





Example :  i have a screen 100 which is designed as Model Dialog box.I am displaying this screen from FM.

Ex code :

FUNCTION Fun_name.

CALL SCREEN 100 STARTING AT 10 01
                                   ENDING AT 50 05.

ENDFUNCTION.


Screen 100:

PBO :

MODULE Status_100.

CODE in O01 Include:

MODULE status_100.
SET PF-STATUS 'Z100'.
ENDMODULE.

GUI Status Creation  for model dialog box:
Double click on Z100 and select Model dialog box radio button from pop up screen by providing meaningful description.

After that Create your Application Tool bar Buttons as per the requirement, while creating buttons we have to provide function keys to the buttons.
If you provide function key as ENTER to any Function code of button , It will automatically enable CLOSE (X) button in Model Dialog box.

Solution :

1. SET PF-STATUS 'Z100'. EXCLUDING 'FC_CLOSE'.
      Here 'FC_CLOSE' is the function code assigned to ENTER function key.

2.Remove the Function code Assigned to ENTER function key .


Sunday, September 10, 2017

OOP Report : Backgroung job cancelled in SAP ABAP


Problem : When we are running ALV OOP report as background job , Sometimes will get status as cancelled in SM37.


Solution :

Step 1 : Check the container used for holding the ALV Report . If the container used is CL_GUI_CUSTOM_CONTAINER , then it is not possible to run report in background.

Solution : Replace CL_GUI_CUSTOM_CONTAINER object reference with CL_GUI_DOCKING_CONTAINER. Now it's possible to run report as background job.


Note : If you are using CL_GUI_DOCKING_CONTAINER , no need of creating object .Just pass the referece to CL_GUI_ALV_GRID object creation.

Signature :

CREATE OBJECT obj_grid
Exporting

i_parent  = obj_docking_container
.

Sunday, May 28, 2017

PF STATUS for Selection Screen

In this post we are going to learn , how to set PF-STATUS for standard selection screen ( SCREEN #: 1000)

i will explain this by taking small example.


Report Zvenky_pfstatus.

Tables : MARA.

SELECT-OPTIONS :   s_matnr FOR mara-matnr.



If you execute the above piece of code, you will get a selection screen with s_matnr as select option.
Here in output you will get GUI status with Back,Exit and Cancel button.This status automatically provided by SAP.

Now here my requirement is , i want to display my own PF-STATUS for Standard Selection screen.

we can implement this very easily with help of SAP Standard FM 'RS_SET_SEL_SCREEN_STATUS'.

Example.

Report Zvenky_pfstatus.

Tables : MARA.

SELECT-OPTIONS :   s_matnr FOR mara-matnr.

AT SELECTION-SCREEN OUTPUT.   " Event which will trigger before Selection screen display

CALL FUNCTION 'RS_SET_SEL_SCREEN_STATUS'
EXPORTING
p_status = 'ZSTATUS'    " user created status
*p_program = ' '

TABLES
p_exclude = itab_exclude .   " itab_exclude type standard table of rsexfcode


By Using above piece of code we can display our own GUI Status.

Note : In Standard gui status Back,Exit,Cancel Buttons will work automatically ,as the button functionality will take by SAP. But if you display your own GUI status ,You have to write code for Button action.


P_EXCLUDE : Table of OK codes to be excluded.