jueves, 30 de junio de 2011

SALV with Drill Down to open an Invoice

To achieve this we need to handle the event double click so check first the post: SALV Handle double click

After doing that in the implementation part we only need to call the function RV_CALL_DISPLAY_TRANSACTION passing the vbeln that must be at the table mapped to the ALV:

CLASS lcl_handler IMPLEMENTATION.
METHOD on_double_click.
READ TABLE SALVTable INTO WA_SALVTable INDEX row.
IF sy-subrc = 0.
CALL FUNCTION 'RV_CALL_DISPLAY_TRANSACTION'
EXPORTING
vbeln = WA_SALVTable-vbeln.
ENDIF.
ENDMETHOD.
ENDCLASS.

SALV Handle double click

To andle the Double Click event of SALV, we need to declare a handler class:

Definition:

CLASS lcl_handler DEFINITION.
PUBLIC SECTION.
METHODS: on_double_click FOR EVENT DOUBLE_CLICK OF cl_salv_events_table
IMPORTING row column.
PRIVATE SECTION.
DATA: lr_data_tab TYPE REF TO data.
ENDCLASS.

The method handler returns the row and columns double clicked.

Implementation:

This is what the method must do after a row is double clicked, reading the table using the row as the index.

CLASS lcl_handler IMPLEMENTATION.
METHOD on_double_click.
READ TABLE SALVTable INTO WA_SALVTable INDEX row.
"...
"...
"...
ENDMETHOD.
ENDCLASS.

Then we need to declare the handler class and cl_salv_events_table class as REF TO

DATA: r_events TYPE REF TO cl_salv_events_table,
event_handler type ref to lcl_handler.

We gets the event object from the alv object created by factory method of cl_salv_table:

r_events = alv->get_event( ).

Then Create the event handler

CREATE OBJECT event_handler.

Sets the handler method for the ALV corresponding event

SET HANDLER event_handler->on_double_click FOR r_events.

We are finished.

SALV Set Light or Exception field

The table to be mapped must have a light field, the name does not matter, the possible colors are:
1.-Rojo,2.-Verde,3.-Amarillo

Example:
SalvTable-Light = 1."ROJO.

After constructing the ALV with factory method of cl_salv_table

cl_salv_table=>factory(
IMPORTING r_salv_table = alv
CHANGING t_table = SALVTable ).

g_columns = ALV->get_columns( ).
g_columns->set_exception_column( value = 'LIGHT' ).

SALV Row Colors

To set Color for a Row the table we are going to map to the ALV must have a field of type lvc_t_scol and fill the color structure:

Declare:

DATA: lt_s_color TYPE lvc_t_scol,
ls_s_color TYPE lvc_s_scol.

Fill structure

ls_s_color-color-int = 0. "Intensive
ls_s_color-color-inv = 0."Inverse
" 1 = grey/blue, 2=light grey, 3=yellow, 4=blue/green, 5= green, 6=red, 7=orange.
ls_s_color-color-col = 3."Color
APPEND ls_s_color TO lt_s_color.

Fill the Tab to be mapped,

WA_SALVTab-ROW_COLOUR = lt_s_color.
APPEND WA_SALVTab TO T_SALVTab.

SALV Hide columns

Hi,

If we want to hide some columns from the ALV that come with the table mapped, we just need to set the column as technical executing the method SET_TECHNICAL to True:

g_column ?= g_columns->get_column( 'PROC_CODE' ).
g_column->SET_TECHNICAL( ABAP_TRUE ).

OR

Set the column visible property as False:

g_column ?= g_columns->get_column( 'MSGTYP' ).
g_column->SET_VISIBLE( ABAP_FALSE ).

Greetings.

miércoles, 29 de junio de 2011

SALV Set Header Column Text

Hi,

To Set the Text we want to be showed at the column header of one SALV we first need to have been declared some vars:

First our ALV object TYPE REF TO cl_salv_table
Then we need another one to be the column collection TYPE REF TO cl_salv_columns_table
Finally a csingle column var of TYPE REF TO cl_salv_column_table.

After that we now need to create the salv Object using the factory method of cl_salv_table Class, we need to the table that we want the Alv shows data.

Creating the SALV:

cl_salv_table=>factory(
IMPORTING r_salv_table = alv
CHANGING t_table = T_tableView ).

Now we are going to set the column header texts, getting first the column collection from the ALV object created:

g_columns = ALV->get_columns( ).
TRY.
g_columns->set_color_column( 'ROW_COLOUR' ).
g_columns->set_key_fixation( ).
CATCH cx_salv_data_error. "#EC NO_HANDLER
ENDTRY.

at this point we have a collection of columns, now we are going to find an especific column:

executing the get_column method passing the column field name mapped in the alv and saving the result to the column var.

g_column ?= g_columns->get_column( 'MESSAGE' ).

now we can set the header text for the MESSAGE column of the SALV, short,medium and long text:

g_column->set_short_text( value = 'Mensaje' ).
g_column->set_medium_text( value = 'Mensaje' ).
g_column->set_long_text( value = 'Mensaje' ).

hope it helps.

Consuming Web Service from URL/HTTP Destination

Hi,

We can use a Web service firstly declaring a Client Proxy at SE80
following this Enterprise Services-->Client Proxies-->Create

Selecting the option URL/HTTP Destination and then Continue, now we need to fill the URL where the service WSDL are and press continue.

Remember that the URL must have the domain name.

Insert the Package,Prefix, Request and continue, Configure and continue.

If the SAP version is ECC 6.0 or + then we have to configure the port at Tx. SOAMANAGER that opens the Default Web Browser with a SOA Management WebDynpro, select the Tab Application and Scenario Communication and then click in Single Service Administration, we are going to search by Proxy with pattern z* & press GO.

A Grid is filled out with a list of entities found, now we select the proxy and press Apply Selection Button, in the Tab Configurations we have to add a Logical Port by pressing Create Logical Port, then we havce to fill the port name,description and again insert the wsdl url finiching by pressing Apply Settings.

At the port created Config's Tab's I supressed the Message ID Protocol at Messaging Tab.

Now we can consume that Web Service throug the Logical Port of our Client Proxy, How to do it?

1.- Define some var_pxyName at the program of TYPE REF TO the proxy Name.
2.-Declare Input & Output vars of type Param Input & Output: ls_request, ls_response.
3.- Implement or Set the var using CREATE OBJECT var_pxyName
4.-Call the WS Method trough proxy, 
    CALL METHOD varProxyName->MyMethod
            EXPORTING
        INPUT = LS_REQUEST
      IMPORTING
        OUTPUT = ls_response .

5.- Finally we have to check the ls_response with the WS Result.

Greetings