Sunday, December 29, 2013

How to access one context node's data from another context node

Assume we have 2 context nodes BUILHEADER(Header) and BUILROLES(Roles). And from Roles context node class if we need to access Header CN:

1. Create an attribute ZHEADER type ref to ZL_ZROLES_ROLESLIST_CN01 in the Roles context node class.


2. In the Create Header method of context node class add the following code.



3. In the get_attr method of the Roles context node, the header context node can be accessed.



Setting for navigation between components

What settings are to be done to navigate between components -

1. From the outbound plug of your source window call( ).
nav_service = cl_crm_ui_navigation_service=>get_instance

CALL METHOD nav_service->navigate
EXPORTING

iv_link_id
= linkid. The link id is your logical link id.

2. Create your logical link with a target id and an object type. You can get a target id when you create a inbound plug entries for your target view/window.

3. In CRMC_UI_NBLINKS connect the logical link, target id and the object type.

Creating a view in CRM WEB UI

Custom BO creation:
A BOL entity is a business object whose structure is same as the structure you want to display in your view. A BOL entity is of type CL_CRM_BOL_ENTITY.
How to create a BOL entity if there does not exist one with the structure you need?
1. First create a DB table in SE11, with all the fields you need in your view.
2. Then create a lock object for this view with the kind of lock you need.
3. Now assign a BO to this table and lock object in the view CRMV_TBLOBJ_OBJ
4. Now in SPRO->CRM->CROSS APP COMP->GENIL COMP->SPECIAL SETTING->DEFINE BO, mention your BO, DB table, Interface details.
This completes creation of a BO.

Creating a table view:
1. Create a table view with the desired context node.
2. Create the buttons in the controller class, and set the CONFIG TABLE details in the .htm page to set the table config.
3. Create buttons CREATE, EDIT, DELETE in the DO_PREPARE_OUTPUT method of the view controller class.
4. Add event handler methods for each of the buttons.
Code details:
You use the component controller(CoCo) of the component to access the context nodes of other views in the component. CoCo basically acts like a global place holder and context nodes assigned to component controller can be accessed from any view's controller class.
How to access a context node of some other view from your custom view?
lr_comp ?= me->comp_controller
lr_comp->typed_context->campaign->collection_wrapper->get_current( ).
5. Create a ON_NEW_FOCUS method which acts as a event handler for NEW_FOCUS event.
This method is used to determine the BOL entities of dependent model nodes as a collection at run time and to assign them to the collection wrapper of the dependent model node. In other words, if the focus of the collection of the leading context node changes, its collection wrapper sends a NEW_FOCUS event to the dependent collection node which updates its context structure accordingly. This event is triggered by the publish_current method of the collection_wrapper of your leading context node.
The ON_NEW_FOCUS method is created in the context node class of your view and set that as an event handler method for the class CL_BSP_WD_COLLECTION_WRAPPER and event NEW_FOCUS.
Go to CTXT class of Order and in the CONNECT_NODES method set the handler to activate 
coll_wrapper = campaign->get_collection_wrapper
set HANDLER me->order->on_new_focus for coll_wrapper ACTIVATION iv_activate.
6. For the SAVE action:
You have used the component controller to access other views context node, now for other views to access your context node your context node has to be tied up to the component controller. The save is in the over view page, and to inform the Save button that there is an other view which it has to save and commit, we tie the data/context nodes to the component controller.
In the create_order method of your context class, after the binding call the ON_NEW_FOCUS method so that we can pass the entity or the FOCUS_BO parameter to the ON_NEW_FOCUS method.
In the save action:
get, the current entity and add it to the transaction context and transaction manager saves and commits all the bol collection at a time.
A transaction context is like a buffer where all the bol entities are stored, and after the save action all the bol entities are together saved and committed to the DB.
At the end also call the publish_current method  from the collection wrapper class.
7. ON_NEW_FOCUS method: In here you write the query method to get the query result and display your output. In addition to this you can also set conditions to inform the view about when it has to fetch the data.

Custom controller

1. How to configure a .htm page to get the CONFIGURATION tab?

<chtmlb: config mode       = "RUNTIME"
                 display mode   = "TRUE"
                 xml                  = "<%= controller->configuration_descr->get_config_data( ) %>" />


2. Details on Custom Controller?

A Custom Controller is used when you want to access data from one view in an other view belonging to the same component.
To do this -
1. You can use the wizard, create a CuCo and attach the context node. By doing this the binding is done by the wizard itself and you need not add any other extra code piece to bind the CuCo and the context node.
2. Now for ex: You have a table in your new custom view for which you have the CuCo, and the save event is obviously in your main over view page. Now how does your CuCo help your save event no that there is another context node data that has to be saved?
  • Create a ref variable which is of type your component controller, this class has an attribute COMP_CONTROLLER, we need to access this component.
  • Through this COMP_CONTROLLER's ZTYPED_CONTEXT attribute we access the context node, the collection wrapper. With this we will have access to the TRANSACTION CONTEXT which is added to the save context and saved and committed.

Creating a BSP component

1. Tcode BSP_WD_CMPWB
2. Add a model, if you do not know the component set you can use ALL, but make sure you add the right component set because the right one can only give you your desired BO entity.
3. To get config page, in the details page add
<chtmlb:overviewFormConfig/>
4. An overview page does not have .htm
5. You create all the views you need, and all those views/assignment blocks are to be added into the over view page. You don't add any fields in the over view page as such. All the over view page has multiple assignment blocks. So as the over view page is a combination of many views, it can be called a view set.
6. .htm page
This page takes care of configuring your config tab or any buttons you have etc.
chtmlb is the name space for configuration
thtmlb is the name space for toolbar
Ex: You want to add a button in a particular view -
First add a button in the IMPL class of the view,
Add properties for the button in the DO_PREPARE_OUTPUT method.
Once the button is ready, you need to give a position where you need the button to be displayed that can be done in the toolbar.
< thtmlb toolbar is the bsp extension for toolbar that SAP has provided now pass the parameters it needs to put your button in the toolbar of your view.
like
<thtmlb toolbar id                    = "HeaderToolbar"
                        buttons            = <%= controller->gt_button %>
                        maxButtonNumber  = "3"
                        foreignUse = "TRUE" />

For data to flow between 2 views what we need is plugs and navigation link to connect these plugs.
To navigate between 2 views, create outbound plug, inbound plug and navigational link.
To add a button to navigate back from the toolbar, we can follow the same procedure as mentioned above for the edit button. But for this we got to make sure that there is a BSP extension for the toolbar call back. Otherwise, include the necessary interface in your IMPL class and implement the necessary methods.

Custom controller needs to be created to pass data between 2 views. And after creating it has to be bound with the view so that the view data can be accessible to other views.

Wednesday, October 9, 2013

Navigating between components

If your search list has a customer and you want to navigate to the BP details.

1. Get_P method
CASE iv_property.
WHEN if_bsp_wd_model_setter_getter=>fp_fieldtype.
rv_value = cl_bsp_dlc_view_descriptor=>field_type_event_link.
WHEN if_bsp_wd_model_setter_getter=>fp_onclick.
rv_value = 'SOLDTO'.                               
WHEN if_bsp_wd_model_setter_getter=>fp_tooltip.
ENDCASE.

2. Get navigation index
cl_thtmlb_util=>get_event_info(
EXPORTING
iv_event = htmlb_event_ex
IMPORTING

ev_index = lv_index ).

* get entity without setting the current
lr_entity ?= me->typed_context->btqrslsord->get_bo_by_index(
iv_index = lv_index
iv_change_focus = abap_false )


3. How to call windows outbound plug from your view's outbound plug
lr_window = me->view_manager->get_window_controller( ).
lr_window->call_outbound_plug( iv_outbound_plug = '         '
                                                           iv_data_collection = iv_data_collection ).

4. To Navigate to an other account make sure, the respective object type is maintained in the outbound plug mappings in navigation bar links of your component.

5. Using the index, once the entity is obtained, create a descriptor object
  CALL METHOD cl_crm_ui_descriptor_obj_srv=>create_entity_based
    EXPORTING
      ir_entity           = lr_entity
      iv_ui_object_action = 'B'
    RECEIVING
      rr_result           = lr_nav_descr.


6. From the descriptor object,SAP understands what kind of BO you are working on. And it knows what kind of a object type you need to have in order to navigate to the respective overview page.

7. Now it checks whether you have the respective dynamic navigation set up for your component. For this make sure the BP_ACCOUNT object type is set up on your navigation bar outbound plug mappings.
IF lr_nav_serv->is_dynamic_nav_supported( ir_descriptor_object = lr_nav_descr ) EQ abap_true.

8. Add this descriptor object to your collection which holds your selected entity.

9.And call the method navigate_dynamically and give your collection.
lr_nav_serv->navigate_dynamically( iv_data_collection = iv_data_collection ).

 


Friday, April 12, 2013

One stop answers

1. The types of tables in SAP?
  1. Transparent table
  2. Pooled table
  3. Cluster table
Pooled and cluster tables are generally used when large volumes of data needs to be stored. This tables are primarily used by SAP. These tables are used to improve performance in scenarios where same kind of tables or tables with same primary key fields are grouped together because SAP extraction becomes easy.
Pool and cluster tables are the tables that are assigned to table pool and cluster pools.
SE11->Utilities->Other dictionary objects->Select radio button cluster/pool name and give a pool name->give the tabname and varkey lengths and data type->save and activate.
Now goto SE11->create a ztable and choose table category option from the menu and choose table type as pooled table-> in delivery maintenance option in technical settings give pool/cluster name.
This is how a pool table is created.

2. Is there a way to set up a sequence to the implementations of a multiple-use BADI?

BADI_SORTER is the answer.  Create a new implementation to this BADI. Now for this BADI set up a filter with the field being BADI_NAME and the value being the name of the BADI you want to set up the sort sequence for. Implement the method IF_BADI_SORTER according to your sort criterion.

3. What is a dynamic internal table and its advantages?

A dynamic internal table is used when the number or rows required are decided only at runtime.
Advantages:
1. Very flexible
2. Avoids Redundancy
Some of the important attributes of an internal table which can be set dynamically are
  • Column position
  • Field name of internal table field
  • Column width
  • Reference field
  • Reference table
  • Data type of the fields
  • Domain name of the fields
  • Check table
4. What are field symbols?

Field symbols are like the pointers in C. They are direct pointers to the address of the value in a field. These are very much useful in performance improvement.
Field symbols can be used inside the loop too. And are particularly useful in the append statements to avoid declaring extra work areas.
Ex:
<fs_1>-name = gv_name.
<fs_1>-num = gv_num.
append <fs_1> to gt_num.

Field symbols are also useful in extracting data from other programs.
Identify the program which  can give you your desired value.
gv_val = (PROGRAM)evbak-vbeln.
ASSIGN gv_val to <fs_1>.
gv_val1 = <fs_1>.
Here gv_val is a variable of type char and gv_val1 is of the required field type or table type. Since field symbol can be of any type it will automatically take the field or the table type when the value is assigned to it. Hence gv_val1 which is of the exact field type or table type could accept the data from the field symbol.

5. What is a Update function module?
Update function modules are necessary when you want a certain part of your program to run after DB updates. That is, lets say your program is updating a DB after a particular occurrence and as soon as the DB updates you want a indicator to be set for further processing, in this case you can use a update function module which will run only after a COMMIT WORK appears.
Syntax: CALL FUNCTION 'func' IN UPDATE TASK
            Exp
When the compiler sees this statement, it wont go into the function module to execute it but skips and goes to the next line of code. At the end of the program when it sees the COMMIT WORK statement all the update tasks begin to execute.
To function module to run in update task the process type of the function module should be set to one of the below -
Update with immediate start
Update with immediate start and no restart
Update with delayed start.

6. What is a LUW?
A logical unit of work is an inseparable sequence of DB actions that either must be fully completed or completely rolled back. They are those sequence of actions that together form one business transaction. Also in other words its the span of time during which 2 DB operations are performed. It is primarily useful in keeping the DB integrity.
There are 3 types of LUW -
DB transaction which is otherwise called LUW -
Its the time between the operation initiated must be either completed as a unit or no operation should happen. When we are talking of LUW it generally is because of the implicit COMMIT WORK statements.
Update transaction which is also call the SAP LUW -
SAP LUW is a bundle of different LUWs. To avoid errors SAP bundles all the LUWs into a single LUW and commits them in a single go to the DB. Generally an SAP LUW ends with an explicit COMMIT WORK statement.

7. What is SAP memory and ABAP memory?
SAP memory is like the global data which all the main sessions have access to. To extract data from SAP memory use SET/GET parameters.
SET PARAMETER ID ' ' field ' ',
CALL TRANSACTION ' ' .
ABAP memory is the local data. It is the memory that all the programs within the same internal session can access using the EXPORT and IMPORT statements.
Ex: During a particular execution of a program or a transaction, two exits are being called. You want to use a value from exit1 in exit2. So in exit1 you can use a EXPORT statement to a memory id and import the same from the same memory id in exit2. Here you are the local ABAP memory.

8. Transport request TCodes?
To organize transport requests SE09 , SE10
To move TRs from one client to other SCC1.

9. How to debug a background job?
Go to SM37, select your job and in the transaction screen give /JDBG. Make sure you put a breakpoint in your program. The compiler will stop in your program at the breakpoint.
Note: This debugging will only help you to traverse through your program for the previously ran test data. Particularly useful to find out the reason for a job cancel.

10. Difference between CLEAR, REFRESH and FREE?
CLEAR: This statement clears the workarea
REFRESH: Clears the internal table contents.
FREE: Clears the contents and also frees the allocated memory to the table.





 

Monday, April 8, 2013

Understanding RICEFW - Interfaces

Interface programming is responsible of making SAP communicate with external systems. 
How does SAP do this?
1. File Interface for reading and writing files.
2. RFC
3. BAPI
4. ALE & EDI

File system:
This is a good way to exchange data between 2 systems. The legacy system writes data to a file, this file is transported into the target SAP system, the target system reads the data in the file and writes it to the DB.  SAP has many such importing programs like -
CALL TRANSACTION:
How do you use one?
CALL TRANSACTION <TCODE>
USING <BDC_TAB>
MODE <MOD>
UPDATE<UPDATE>
MESSAGES INTO <TABLE>

1. Prepare a DB table with bdcdata specific to the transaction
<bdc_tab>-prognam
<bdc_tab>-dynpro
<bdc_tab>-dynbegin
 append <bdc_dat>

2. MODE can be A, N, E. Where in you can mention how you want the data transfer process be displayed.
A - Display All (All screens and the data)
N - No display (Even if there are errors, the screens are processed invisibly)
E - Display only errors.

3. UPDATE
A - Asynchronous - COMMIT WORK
S - Synchronous - COMMIT WORK AND WAIT
L - Local - SET UPDATE TASK LOCAL

BATCH INPUT:
The main advantage of batch input is the controlling and correction of errors.
BDC Programming is the batch interface technique in sap. But the batch input is little slower compared to the call transaction. The batch input is especially advantageous when transferring large amounts of data.
SHDB is the transaction, to perform a session recording.

RFC:
The ABAP function modules can be called from external systems using the RFC function protocol.
All the parameters in an RFC must be referenced to the ABAP dictionary and all of them must be passed by value. From version 6.0 RFCs also include changing parameters. The destination parameter is the one which lets the rfc function modules be called from other external systems. To create a destination use the tcode SM59.

BAPI:
Business Object (BO) gives an object oriented view of the business data and transactions. A BOR consists of the object types of these BO. To maintain a BOR SW0 and SW01 are to be used. The methods of some object types are identified as BAPI, and BAPIs are commonly used for RFC purposes.
The reason why BAPIs amongst all the methods of BO types have become so famous is
BAPIs have stable interface, meaning the interface is not changed by any new release of SAP.
BAPIs do not trigger exceptions, they only give return parameters.
DBs are updated in an update task, meaning BAPIs perform updates by calling an update module  CALL FUNCTION IN BACKGROUND TASK. A commit work or a rollback work is not committed in a BAPI.

EDI:
EDI is used for exchanging data between 2 systems for which an IDOC structure is required. An IDOC consists of DATA, CONTROL and STATUS records.
ALE is also a similar technology, but it is used to transfer data internally, but if it is data transfer between SAP and an external system EDI is the one which is generally preferred.
IDOC:
To create segments - WE31
To create IDOC - WE30
Create or assign message type - WE81/WE82
Partner profile set up - WE20

RSNAST00 program is used when batch input process is set.
Ex: In a sales order output the processing mode should be set to 1 and not to 4 which is immediate processing. RSNAST00 program picks up all the outputs whose processing mode is set to 1 from the NAST table and executes the data and gives an outbound idoc.

CHANGE POINTERS:
It is the process in SAP which triggers every time there is a change in the master data. Change pointer is something similar to the CDPOS and CDHDR.
BD50- Activate change pointer in a message type
BD52- Create change document item
BD61- Activate change pointer globally
Change pointers are captured in table BDCPS and BDCP
BD20 - To create IDOC from change pointers. (Report RBDMIDOC)
BD20 - To delete change pointer entries.

Sunday, April 7, 2013

Understanding RICEFW - Reports

Learning RICEFW is essentially learning the technical part of SAP.

R ->  Reports
I  ->  Interfaces
C ->  Conversions
E ->  Extensions
F ->  Forms
W-> Workflows
 
Important concepts of each of these 6 categories.
 
Reports:
Reporting is used so that large amount of consolidated data which is essentially stored in multiple tables can be viewed in one go based on any selection criteria one might need.
Reports are executable programs, meaning in SE38 when you are creating a program,  
select the program type as Executable program.
 
SAP provides as basic as the write statements letting one program their own reports to as advanced as direct function modules which when fed by the respective input internal table will display the report.
 
The various function modules that we have for reporting are
- REUSE_ALV_LIST_DISPLAY - This displays the output in the format of an ALV LIST
- REUSE_ALV_GRID_DISPLAY - This displays the output in the format of an ALV GRID
- REUSE_ALV_GRID_DIPLAY_TREE - For when information is needed to be displayed in the form of tree.
 
The same can be done in OOPS, where in there are many methods to perform the same functionalities like the SET_TABLE_FOR_FIRST_DISPLAY in the class CL_GUI_ALV_GRID.
 
SAP also supports interactive reporting, where in navigation can be done between the report output and its details screen (Details screen meaning, if the user clicks on a particular line of the report a new report opens up with the respective details as per requirement. Ex: Consider in a particular report user clicks on the field sold-to-party on a row, then another screen appears giving details about all the sales orders of this sold-to-party's name).
 
REPORT EVENTS:
 
Reports are event driven. And the different events in-sequence that a report execution encounters are as below -

1. LOAD-OF-PROGRAM -
As the name says this event is used to load the module pool, function module, subroutine pool programs into the executable program. This event occurs only once during a particular execution. And this program is pretty much something like a constructor of a class.

2. INITIALIZATION -
This event is executed before the selection screen is displayed, and this provides an opportunity to initialize values on selection screen.

3. AT SELECTION-SCREEN -
This event is processed after the initialization, and it is primarily used to validate the selection screen values. In other words, as soon as the user enters values in the selection screen and executes this event is processed which validates the values entered by the user and displays any error message if the values entered are not appropriate.

The types of selection screen events are -
  • At Selection-Screen Output.
  • At Selection-Screen On Value Request For <Field>.
  • At Selection-Screen On Help Request For <Field>.
  • At Selection-Screen On <field- select-options>.
  • At Selection-Screen On <field-Parameter>.
  • At Selection-Screen On Block <blockname>.
  • At Selection-Screen On Radiobutton Group <groupname>.
  • At Selection-Screen.
  •  
    AT SELECTION SCREEN OUTPUT -
    Actually this event occurs in between INITIALIZATION and AT SELECTION-SCREEN. This event is used to dynamically change the properties of the selection screen. In other words, this event allows us to modify the selection screen even before it is displayed for the first time. For ex: When the selection screen first appears the user wants to see few fields intensified ON and few intensified OFF, this can be achieved by this event.
     
    AT SELECTION SCREEN ON VALUE REQUEST FOR <FIELD> -
    This event gets triggered when the F4 option is pressed on a field. This is particularly useful if you have your own set of data that you want to display when user presses F4.
    Note: If this F4 is for select option, It needs to be mentioned twice once for low and other for the high.
    Ex: Prepare a table with all the values you want to display when the user presses F4.
    Say the table is gt_kna1,
    AT SELECTION SCREEN ON VALUE REQUEST FOR s_kunnr-low.
     
    CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
    EXPORTING
    retfield = 'KUNNR'
    dynprofield = 'S_KUNNR'
    dynpprog = sy-prog
    dynpnr = sy-dynnr
    value_org = 'S'
    TABLES
    value_tab = gt_kna1.
    Similarly for the high field that is s_kunnr-high.
     
    AT SELECTION SCREEN ON HELP REQUEST FOR <FIELD> -
    This is very similar to the above value request, except that a help documentation is provided when the user presses F1.
    Note: In both cases, because the selection screen parameters are of the data type the corresponding data element the default F4 and F1 help appear. If these events are used the standard F1 and F4 helps are overwritten.
     
    Now prepare the Help table with attributes -

    gt_help-tabname = ''.
    gt_help-fieldname = ''.
    gt_help-keyword = ''.
    gt_help-length = ''.
    gt_help-value = ''
    APPEND gt_help.
     
    CALL FUNCTION 'HELP_GET_VALUES'
    EXPORTING
    popup_title = ''
    TABLES
    fields = gt_help
    EXCEPTIONS
    no_entries = 1
    OTHERS = 2.
     
    AT SELECTION-SCREEN ON -
    This is pretty much same like the AT SELECTION-SCREEN used to validate the selection screen values, except that the AT SELECTION-SCREEN validates all the values but the AT SELECTION-SCREEN ON validates only the field it is used on -
    Ex:
    AT SELECTION-SCREEN ON s_kunnr.
    If s_kunnr is initial.
    MESSAGE 'Please enter the sold-to-party value', TYPE 'E'.
    Endif.
     
    4. START-OF-SELECTION -
        Data selection from the data base tables is done here.

    5. END-OF-SELECTION -
        From the start-of-selection one output table which is a consolidation of all the data
        (the final internal table) is prepared and at the end-of-selection this output is written
        to display.

    6. AT LINE-SELECTION -
        This event is specific to interactive reporting. On the primary screen of an output, if
        the user clicks on a row or a field and expects an event to happen, code for this can be
        written under this event. The AT LINE-SELECTION populates few system fields which
        will help capturing the row or the field that has been selected.
        SY-LSIND is tone such system field which holds the number of the detail list.
        For Basic or primary list SY-LSIND is zero, for first detail list SY-LSIND = 1.
        A particular report can have 0 to 22 details screens.
        GET CURSOR FIELD fname value fval - this give the value on which the user has clicked.
        HIDE - Hide is a keyword which stores values of specific key fields in the memory along 
        with the sy-linno system field.
        This statement is used within a loop while displaying that is in END-OF-SELECTION. All  
        the fields that you think you might use can be displayed using this keyword, and can
        be used to display the interactive report.
        Interactive reporting can as well be done using the I_CALLBACK_USER_COMMAND of the
        reuse_alv function module.
       
             Unlike the topics discussed earlier, there are other process control events that can be used to extract data and prepare the final internal table.
    AT FIRST - Beginning of the loop
    AT NEW - At every new occurrence of the field
    AT END OF - At the end of a particular occurrence
    AT LAST - At the end of the loop.
    All these events are to used within a loop.

    TOP-OF-PAGE -
    This event is triggered when the first write statement is seen. When the controller sees the first write statement, it will go and check if top-of-page event is present, If yes it will execute whatever is present in there like the title, column headings etc.
    Ex:
    TOP-OF-PAGE
    FORMAT COLOR 1.
    WRITE: ' Customer Details'.
    FORMAT COLOR 1 OFF.
    ULINE.

    TOP_OF_PAGE DURING LINE_SELECTION -
    This keyword lets us provide TOP-OF-PAGE for secondary lists
    Ex:
    TOP_OF_PAGE DURING LINE_SELECTION
    If sy-lsind = 1. (First detail list)


    Endif.

    Few important notes to remember about reporting -
     
    1. Report  <ZMNS_CUSTOMER_ORDERS> This is the first line of any report.
     
    2. KEYWORDS to format the report layout -
    • To avoid heading - NO STANDARD PAGE HEADING is the keyword  
              Syntax: Report  <ZMNS_CUSTOMER_ORDERS> NO STANDARD PAGE HEADING
     
    • To specify the length of the column in a report - LINE-SIZE
             Syntax: Report  <ZMNS_CUSTOMER_ORDERS> LINE-SIZE 40
             The system field sy-linsz is set with this keyword.
    • To specify the length of the page in a report - LINE-COUNT page_lines(footer_lines)
             Syntax: Report  <ZMNS_CUSTOMER_ORDERS>  LINE-COUNT 0(2)
             The page_lines if mentioned 0 is by default set to 60000 by the system and the 2 
             meaning 2 lines are reserved for the footer. Note, a footer cannot be set for the
             detail list.
             The system field sy-linct is set with this keyword.
             The footer must be set under END_OF_PAGE keyword.
    • NEW-PAGE - If all the above settings, like the count, title, header and all need to be valid only for the first page, new settings for the next individual page can be set using the NEW-PAGE keyword.
    • Syntax: NEW-PAGE <NO-TITLE> <NO-HEADING>
     
    Selection screen:
     
    Syntax:
    Selection screen begin of screen <>
     
    Selection screen end of screen <>
     
    Selection screen parameters can be either PARAMETERS or SELECT-OPTIONS.
     
    PARAMETERS are single valued entries:
    Ex: PARAMETER  pa_kunnr type kunnr DEFAULT '108183'. 
    The default keyword is optional, in case you want to run the report for the same value always.

    PARAMETER as checkbox:
    Ex: PARAMETER pa_c AS CHECKBOX DEFAULT 'X'.
     
    PARAMETER as radio button:
    Ex: PARAMETER: pa_rb1 radio button group rad1 DEFAULT 'X'
                             pa_rb2 radio button group rad1.
     
    SELECT_OPTIONS :
    Ex: s_vbeln for vbak-vbeln.
    Used when range of values are to be used.
     
    LAYOUT TIPS :
    - For color use syntax - FORMAT COLOR n, n is the number of the color.

    - HOTSPOT - If the requirement is to call a detail screen when the user clicks on a specific
      field, and to indicate this, a hand symbol can be made to appear when the mouse is
      hovered over that field, this can be achieved by the above keyword.
     
    - The layout of the grid can also be set by setting some values in the field catalog like -
      output length, hotspot on, sel_text etc.
     
    - Also the layout exporting parameter can also be used to perform layout settings like  
      no_toolbar, grid_title etc. See CL_GUI_ALVGRID class for the structure of any of these 
      fields.
     
    - Its worth noting about a variable IT_EXCLUDING in the function module  
      REUSE_ALV_GRID_DISPLAY which can be used in cases when the requirement is to display
      only certain buttons on alv grid. Obtain the function codes of the button that are needed
      to be displayed, and add the function codes of those buttons to the it_excluding
      table and pass it on to the function module.
     
    Interactive reporting using OOPS:
    The concept of interactive reporting is pretty much same either using the Standard function module approach or the OOPS approach. In OOPS we have  a method SET_TABLE_FOR_FIRST_DISPLAY to display the report in ALV grid.

    Syntax:

    ** Declare an event class with double click handling method which is of type double_click 
       of CL_GUI_ALV_GRID.

    CLASS event_class DEFINITION.
    PUBLIC SECTION.
       METHODS: handle_double_click FOR EVENT double_click OF cl_gui_alv_grid
                       IMPORTING e_row .
    ENDCLASS.

    As can be seen above this method is for the event DOUBLE_CLICK in the class CL_GUI_ALV_GRID, and e_row is the parameter which will give information about
    the row selected. Once the class is declared, write the respective code under this method that you want to see happen when the user double clicks.

    EX: CLASS event_class IMPLEMENTATION.
           METHOD handle_double_click.
              READ TABLE gt_kunnr INDEX e_row-index INTO gw_kunnr.
              SELECT * FROM kna1
              INTO CORRESPONDING FIELDS OF TABLE gw_kna1
              WHERE kunnr EQ gw_kunnr-kunnr.
              CALL SCREEN 101.
           ENDMETHOD.
         ENDCLASS.

    Now that the method is ready, calling the method is remaining. This will happen after the SET_TABLE_FOR_FIRST_DISPLAY method is called.

    Event_receiver TYPE REF TO event_class.

    CREATE OBJECT event_receiver.

    SET HANDLER Event_receiver->handle_double_click FOR c_alv1.

    This should take care of the interactive reporting. 
     
     
     
     
     
     
     
     
     
     
     
     
     
     

    Friday, April 5, 2013

    Understanding RICEFWs - Enhancements

           Enhancements are the means by which the SAP standard code can be customized as per the clients requirement. This does not require access key as code will be written in SAP provided slots for custom code.

    The type of enhancements:
    1. User exits
    2. Customer exits
        a. Function exits
        b. Screen exits
        c. Menu exits
    3. BADI
    4. Enhancement frameworks
        a. Implicit enhancements
        b. Explicit enhancements

    User Exits:
    The naming convention for user exits is FORM USEREXIT_001 These can be found in SE80. User exits are generally includes which are collected together and added to the SAP standard program. But the disadvantage with the user exits are it needs access key to add/change any code in the exit.

    How to find a user exit?
    Get the package name of the transaction/program etc. Go to SMOD, press F4 in the enhancement field. Press information systems button. Give the package name in the popup and a list of user exits are displayed pertinent to the package.

    Customer exits:
    Customer exits are also pre existing slots provided by SAP, but the advantage with the customer exits is they do not need any access key.
    A basic check to see if a particular program has any customer exits is the keyword
    CALL CUSTOMER-FUNCTION 001. Digging deep into this function, we can find the customer exits available.

    Screen exits:
    Like the CALLL CUSTOMER FUNCTION '001' for function exits, there is CALL CUSTOMER-SUBSCREEN for the screen exits. If this particular keyword is present in the screen program of the screen to be modified it means that a screen exit is available for us to modify the screen.
    Once we have the package the screen exit can be found in SE80, or in SMOD.

    How to find the enhancement for a particular  exit/screen area/menu entries -
    After the customer/function exit is found, go to SMOD and press f4 in the enhancements field, press the button to expand the search options in the search popup. And uncheck all the check boxes except exits function and in the name of the component-field give the exit name. Then the enhancement screen in the SMOD tcode will be populated with the enhancement of that exit. Now go to CMOD and generate the project to code the exit.
    Similarly for screen uncheck exit functions and menu entries and for menu uncheck the exit functions and screen area.

    Another common way to find out exits/BADIs -
    Put a break point in the get_instance method of the class CL_EXITHANDLER, and run the prog/tcode etc. The execution stops at this method every time it finds a BADI or an exit. This way the list of all the exits and BADIs in the executed program can be found.

    BADIs:
    These are also predefined exit points available for developers where code can be written without the necessity of any access key. Unlike the exits most of the BADIs can have multiple implementations, meaning you have a particular slot which is appropriate to insert a certain piece of code but it already has an implementation which will be triggered if a particular condition is satisfied, in this case you can create another implementation to this BADI and set up your own conditions to trigger the BADI.

    Setting up a condition to a BADI can be done using filters.

    Filter dependent BADI:
    A filter dependent BADI is very much useful if want your code in the BADI to be triggered for only certain conditions. A BADI filter is SPECIFIC to the IMPLEMENTATION, meaning filter can be set on any one field that you wish and for any number of values of that field values. 

    How to set a filter?
    Select the checkbox filter-depend, and in the field type choose a data element and below insert a value in the defined filters section. ( insert field appears after the filter-depend checkbox is selected and the badi is activated).
    Note1 : When the filter-depend box is checked and after the badi is activated, an importing parameter fil_val is automatically added to the interface of the badi. Also this parameter is added to all the methods of that particular implementation.

    So when calling this BADI, this new import parameter should also be passed -
    CALL METHOD l_badi_instance ->get_cust_name
    exporting
    kunnr = '300014'
    flt_val = 'DEFAULT_ID'
    importing
    name = lv_name.

    IMPLICIT ENHANCEMENTS:
    Are the ones that we generally use. There are pre-existing locations in an SAP program where the user is allowed to include their code piece. These are very well carried over during upgrade to higher versions.
    In the program, click on the circle button and then go to Edit -> Enhancement operations -> Show implicit enhancement options.
    The general locations for these options are
    - At the beginning and end of a form
    - At the end of the function modules etc.

    EXPLICIT ENHANCEMENTS
    There are 2 types of explicit enhancements
    1. Enhancement point
    2. Enhancement section

    The main difference between both is, enhancement point can have multiple implementations and it exists along with the SAP standard code where as the enhancement section replaces the new code with the existing SAP standard code. Enhancement section can have only one active implementation, this is especially used when we have certain code in the standard SAP program which we want to avoid. And enhancement point can have multiple implementations and hence it can exist along with the standard code.

    How to create an explicit enhancement?
    Goto SE80 and select the desired package and right click on it to create enhancement spot. Create an implementation for this spot and save and activate.
    Now go to your program, place the cursor where you want to create the enhancement spot and in the create enhancement option give your spot and package name.With this the enhancement point gets added to your program.
    Click on the ENHANCE button on the top, enhancement options - > create ->give enhancement impl name -> Place the code and activate. 

    Sunday, February 24, 2013

    Restricting values in drop down

    To restrict values in drop down -
    We have to use get_att_v method and use ddlb_reason attribute in context node class. And this drop down is generally in the header so we have to add this attribute in the CN00 class.
    A private variable with ddlb_reason is created which is used to pass on the drop down values.
    http://scn.sap.com/message/10042735
    Now lets say we have field1 when a specific value is selected in field1's drop down it should display restricted values in field2 drop down. For this write a logic in the get_v method of field1 to populate into ddlb_reason field (which should be displayed as a static attribute). This attribute can be accessed in the get_v method of field2 and be displayed.

    To create and F4 help -
    This can be done in any context node. And all this needs is rv_valuehelp_descriptor. This has a standard code. And is implemented in the GET_V_attr method.
    You need to have the attribute technical name, attribute name, search help name, search id type. Search ID type can be from DDIC - HELP_ID_KIND_NAME
                               Reference structure field - HELP_ID_KIND_COMP
                               Reference data element  - HELP_ID_KIND_DTEL
    http://wiki.sdn.sap.com/wiki/display/CRM/How+to+provide+F4+Help



    CRM basics

    BSPWDV_EHSET_ASG is the table where we can assign an enhancement set to a client. Only one enhancement set can be active for a client at a time. You will only have one entry in this table. To have more than one set active at a point play with the BADI COMPONENT_LOADING.

    To assign a role to a user id - got to transaction SU3 - and mention CRM_UI_PROFILE in parameter tab and give your desired role and save. Looks like at a time only one role can be added in SU3.

    CRMC_UI_PROFILE is the transaction where you can view all the business roles in a system.

    To restrict a value in the F4 help in web, use the Get_V_ method. The RV_VALUEHELP_DESCRIPTOR will be used for this purpose.

    GET_ATTR - Is used to get data of an attribute from the BOL layer to display it on UI.
    SET_ATTR - Is used to set data of an attribute from UI to BOL layer.
    GET_M_ATTR - This gives the meta data of an attribute, like the name of the field, the description of the field, language, key field etc.
    GET_I_ATTR- This method is used to enable or disable a field.
    GET_V_ATTR- This method defines the content of drop down values, F4 help.
    GET_P_ATTR - This defines the property of an attribute whethers it drop down, textbox, F4, checkbox etc. Property of an attribute can be picklist, input, checkbox, link, radio.

    In BSPWDVC_CMP_EXT in SM34 holds all the enhancements that are done under your custom enhancement set. You can remove all most all your enhanced controllers/enhancements in this view or SE80.


    Adding a new field in WEB UI

    Follow the below steps to add a new field in the form view or a search view.

    Show configurable area -
    Create a new field -
    Select an object -
    Select an object part -
    Maintain field attributes -
    Generate and close -
    Add the field in configuration mode, you can also add the same field in search criteria. To traverse through the list or to arrange the position of the new field, use the up down button in the config button in BSP_WD_CMPWB transaction.

    Generate the getter and setter methods of the field. Enable the get_v and get_i methods - Get_v method for rv_value_descriptor and get_i method for enabling the field.


    Method as event handler

    You can create an event handler method by right clicking on the event handler method. Or by adding a method in the IMPL class and add the below attributes as its parameters.
    HTMLB_EVENT is type ref to CL_HTMLB_EVENT and this class uses the interface IF_HTMLB_DATA (input data from HTMLB ).
    The parameters of this class are  -
    event_class = CL_HTMLB_EVENT_SELECTION
    event_server_name = is the event that is clicked on
    event_name = dropdownlistbox
    event_type= select
    Once you add this,  go to DO_HANDLE_EVENT method and check if the below code has been addedd in this method.
      *     Added by wizard
          WHEN 'event_name'.                                    "#EC NOTEXT
            EH_ONeventhtmlb_event    htmlb_event
                        htmlb_event_ex htmlb_event_ex ).
    If this is added, whatever code you write in the method EH_ONevent will successfully be triggered.


    Debit and credit notes

    Debit and credit notes : A debit note is given by a purchaser to a seller when the purchaser returns the items back to the seller and a credit note is then given to the purchaser by the seller.
    A transaction that reduces the amt recievable from the customer is a credit memo and the one which reduces the amt payable to a vendor is a debit memo.
    It is basaically a sales doc which is used in complaints processing to request a credit memo for a customer. A credit memo can be used so that it can be assigned to the relevant open invoices and carry out clearing with them.
    Dunning program : WHy are we taking about one here. If a credit memo is assigned to an invoice and if it completely not able to offset the credit memo against the invoice then it is submitted as a debit memo to a vendor who is to reimburse the amt.after this a multilvele dunning program can be used.
    A dunning program lets you dun customers who are making late payments
    F150 is the tcode for dunning program and it basically outputs to give dunning forms.
    To do the same process in CRM that is to create debi/credit memo in ECC we need to create complaints.But to create a complaint basing on an Invoic reference u have to use a badi CRM_COPY_BADI_EXTERN (check spro) this badi helps you give invoice references but only the ones in crm for the ones in ECC got to write some code with a remote function module which fetches data from ECC.

    CRMXIF_PARTNER_SAVE

    CRMXIF_PARTNER_SAVE  - Is a CRM online interface for business partners for external systems.
    This interface has been implemented as in XIF interface.
    Whats is an XIF interface ?
    XIF - External Interface Adapter.  Crm middleware & SAP netweaver interchange adapters convert the data to xml and selects the data that is to be transferred further.When a CRM system is connected to an external system, data ditribution(data flow) can happen via SAP crm middleware or SAP netweaver interchange.
    The business partner interface functions as an inbound and outbound interface and is capable of mass data processing. So this basically looks like the function module of an IDOC with message type as
    CRMXIF_PARTNER_SAVE and idoc type as
    CRMXIF_PARTNER_SAVE01.