HTTP post from ABAP using Object Oriented method

Hi ,
I want to call HTTP from ABAP. I came to know that using classes & objects is the best way to fulfill it.
Interface:
xml_document type ref to cl_xml_document
method post_xml_document.
data: client type ref to if_http_client,
xml_response type ref to cl_xml_document.
data: xml_string type string,
xml_xstring type xstring.
data: zsubrc type sy-subrc.
cl_http_client=>create_by_url( exporting url = 'http://www.example.com/post-url.xml' importing client = client exceptions others = 1 ).
client->request->set_header_field( exporting name = '~request_method' value = 'POST' ).
client->request->set_header_field( exporting name = '~server_protocol' value = 'HTTP/1.1' ).
client->request->set_header_field( exporting name = 'Content-Type' value = 'text/xml' ).
xml_document->render_2_string( exporting pretty_print = 'X' importing stream = xml_string ).
client->request->set_cdata( exporting data = xml_string offset = 0 ).
client->authenticate( exporting proxy_authentication = space username = 'username' password = 'password' ).
client->send( exceptions http_communication_failure = 1 http_invalid_state = 2 ).
client->receive( exceptions http_communication_failure = 1 http_invalid_state = 2 http_processing_failed = 3 ).
xml_xstring = client->response->get_data( ).
zsubrc = xml_response->parse_xstring( stream = xml_xstring ).
endmethod.
Above code can be used to do my work.
Apart from the code in ABAP, what are the configurational setting that we need to do ?
Thanks,
Shivaa..

>
mohammad afzal wrote:
> apart from usin the code u should have configured the RFC destination
Thats nonsense, create_by_url does not need an rfc connection. TA SICF is correct.

Similar Messages

  • Manual HTTP POST from ABAP

    I'm trying to use a kind of botched web service implementation that doesn't come with a WSDL file - so, no generated proxy for me to use. It also needs me to send an XML file via an HTTP POST - not in a SOAP envelope. This presents a problem for me - understandably, this isn't part of WebAS 6.40's web services stuff.
    Does anyone know of a way of manually posting something via HTTP in ABAP? I'm sure there must be some function module or class that exposes that functionality - I just can't find it! Any ideas anyone?

    Hi,
    You can get some idea from following code for your requirment
    DATA: WA_DATA TYPE TSRCLIN,
          WA_RESULT TYPE TY_XML,
          WA_INV_REP TYPE TY_INV_REP,
          T_INV_REP TYPE TABLE OF TY_INV_REP,
          WA_ICA_REC_REP TYPE TY_ICA_REC_REP,
          T_ICA_REC_REP TYPE TABLE OF TY_ICA_REC_REP,
          T_RESULT TYPE T_XML,
          SOURCE_ITAB TYPE ABAP_TRANS_SRCBIND_TAB,
          SOURCE_WA   TYPE ABAP_TRANS_SRCBIND,
          WA_ZTICAUSER TYPE ZTICAUSER.
    DATA: XSLTP TYPE REF TO CL_XSLT_PROCESSOR,
          G_IXML TYPE REF TO IF_IXML,
          G_STREAM_FACTORY TYPE REF TO IF_IXML_STREAM_FACTORY,
          G_ENCODING TYPE REF TO IF_IXML_ENCODING,
          RESSTR TYPE REF TO IF_IXML_OSTREAM,
          HTTP_CLIENT TYPE REF TO IF_HTTP_CLIENT .
    DATA: SURL TYPE STRING.
    DATA: WF_PROXY TYPE STRING ,
          WF_PORT TYPE STRING,
          WF_USER TYPE STRING,
          WF_PASSWORD TYPE STRING,
          RLENGTH TYPE I,
          R_CODE TYPE SY-SUBRC,
          USERID1 TYPE CHAR32.
    CONSTANTS: ENCODING     TYPE STRING VALUE 'UTF-8',
               C_COMMA(1)               VALUE ',',
               C_AP(2)                  VALUE 'AP',
               C_AR(2)                  VALUE 'AR',
               C_CF(2)                  VALUE 'CF',
        CONV->READ( IMPORTING DATA = XMLSTRING LEN = LEN ).
        SPLIT XMLSTRING AT CL_ABAP_CHAR_UTILITIES=>CR_LF INTO TABLE T_DATA.
    * Read Header Information
        READ TABLE T_DATA INDEX 1 INTO WA_DATA.
        SPLIT WA_DATA AT C_COMMA INTO DUMMY SOURCE_SYSTEM_ID DUMMY1.
        TRANSLATE DUMMY TO UPPER CASE.
        CONDENSE DUMMY.
        IF DUMMY <> 'SOURCE SYSTEM ID' OR SOURCE_SYSTEM_ID IS INITIAL.
          STRERROR = C_ERROR6.
        ELSE.
          DELETE T_DATA INDEX 1.
        ENDIF.
        CHECK STRERROR IS INITIAL.
        READ TABLE T_DATA INDEX 1 INTO WA_DATA.
        SPLIT WA_DATA AT C_COMMA INTO DUMMY DATE DUMMY1.
        TRANSLATE DUMMY TO UPPER CASE.
        CONDENSE DUMMY.
        IF DUMMY <> 'DATE' OR DATE IS INITIAL.
          STRERROR = C_ERROR6.
        ELSE.
          DELETE T_DATA INDEX 1.
        ENDIF.
        CHECK STRERROR IS INITIAL.
        READ TABLE T_DATA INDEX 1 INTO WA_DATA.
        SPLIT WA_DATA AT C_COMMA INTO DUMMY TIME DUMMY1.
        TRANSLATE DUMMY TO UPPER CASE.
        CONDENSE DUMMY.
        IF DUMMY <> 'TIME' OR TIME IS INITIAL.
          STRERROR = C_ERROR6.
        ELSE.
          DELETE T_DATA INDEX 1.
        ENDIF.
        CHECK STRERROR IS INITIAL.
        READ TABLE T_DATA INDEX 1 INTO WA_DATA.
        SPLIT WA_DATA AT C_COMMA INTO DUMMY CREATED_BY DUMMY1.
        TRANSLATE DUMMY TO UPPER CASE.
        CONDENSE DUMMY.
        IF DUMMY <> 'CREATED BY' OR CREATED_BY IS INITIAL.
          STRERROR = C_ERROR6.
        ELSE.
          DELETE T_DATA INDEX 1.
        ENDIF.
        CHECK STRERROR IS INITIAL.
        READ TABLE T_DATA INDEX 1 INTO WA_DATA.
        SPLIT WA_DATA AT C_COMMA INTO DUMMY TYPE DUMMY1.
        TRANSLATE DUMMY TO UPPER CASE.
        CONDENSE DUMMY.
        IF DUMMY <> 'TYPE' OR TYPE IS INITIAL.
          STRERROR = C_ERROR6.
        ELSE.
          CONDENSE TYPE.
          L_TYPE1 = REPGRP.
          L_TYPE2 = TYPE.
          TRANSLATE L_TYPE1 TO UPPER CASE.
          CONDENSE L_TYPE1.
          TRANSLATE L_TYPE2 TO UPPER CASE.
          CONDENSE L_TYPE2.
          IF L_TYPE1 NE L_TYPE2.
            IF L_TYPE2 = C_AP.
              CONCATENATE C_ERROR1_AP C_ERROR1
                          INTO STRERROR SEPARATED BY SPACE.
            ELSEIF L_TYPE2 = C_AR.
              CONCATENATE C_ERROR1_AR C_ERROR1
                          INTO STRERROR SEPARATED BY SPACE.
            ELSEIF L_TYPE2 = C_CF.
              CONCATENATE C_ERROR1_CF C_ERROR1
                          INTO STRERROR SEPARATED BY SPACE.
            ENDIF.
          ENDIF.
          DELETE T_DATA INDEX 1.
        ENDIF.
        CHECK STRERROR IS INITIAL.
        DELETE T_DATA INDEX 1.
        LOOP AT T_DATA INTO WA_DATA.
          SPLIT WA_DATA AT ',' INTO WA_RESULT-FITF
                                    WA_RESULT-COUNTERPARTYFITF
                                    WA_RESULT-FUCA
                                    WA_RESULT-COUNTERPARTYFUCA
                                    WA_RESULT-RECONCILIATIONACCOUNT
                                    WA_RESULT-INDICATORCUSTOMERVENDOR
                                    WA_RESULT-INVOICENUMBER
                                    WA_RESULT-DOCUMENTDATE
                                    WA_RESULT-POSTINGDATE
                                    WA_RESULT-DUEDATE
                                    WA_RESULT-INVOICEAMOUNT
                                    WA_RESULT-INVOICECURRENCY
                                    WA_RESULT-REPORTINGAMOUNT
                                    WA_RESULT-REPORTINGCURRENCY
                                    WA_RESULT-INDICATOR
                                    WA_RESULT-CREATIONDATE
                                    WA_RESULT-CLEARINGDATE.
    * Validation of the Structure.                               
          WA_RESULT-SOURCESYSTEM = SOURCE_SYSTEM_ID.
          APPEND WA_RESULT TO T_RESULT.
          WA_INV_REP-INVOICEREPORT = WA_RESULT.
          WA_ICA_REC_REP-ICARECONCILIATIONREPORT = WA_INV_REP.
          WA_ICA_REC_REP-REPGRP = REPGRP.
          WA_ICA_REC_REP-NAMESPACE = C_STR.
          APPEND WA_ICA_REC_REP TO T_ICA_REC_REP.
        ENDLOOP.
        TRY.
            CREATE OBJECT XSLTP.
          CATCH CX_XSLT_EXCEPTION.
        ENDTRY.
        G_IXML = CL_IXML=>CREATE( ).
        G_STREAM_FACTORY = G_IXML->CREATE_STREAM_FACTORY( ).
    ****Create an Endcoding and Byte Order
        G_ENCODING = G_IXML->CREATE_ENCODING( CHARACTER_SET = ENCODING
          BYTE_ORDER = 0 ).
    *****Create Output Stream
        RESSTR =
            G_STREAM_FACTORY->CREATE_OSTREAM_XSTRING( CONTENT ).
    ****Set the Encoding into a stream
        RESSTR->SET_ENCODING( ENCODING = G_ENCODING ).
    * Prepare for Transformation
        SOURCE_WA-NAME = 'BSPXML'.
        GET REFERENCE OF T_ICA_REC_REP INTO SOURCE_WA-VALUE.
        APPEND SOURCE_WA TO SOURCE_ITAB.
        CLEAR XMLSTRING.
        CALL TRANSFORMATION Z_BSP_XSLT
        SOURCE (SOURCE_ITAB)
        RESULT XML XMLSTRING.
        IF SY-SUBRC <> 0.
          STRERROR = C_ERROR3.
        ENDIF.
        DATA: X1 TYPE STRING,
              X2 TYPE STRING.
    * Change encoding from UTF-16 to UTF-8
        SPLIT XMLSTRING AT 'utf-16' INTO X1 X2.
        CLEAR XMLSTRING.
        CONCATENATE X1 'UTF-8' X2 INTO XMLSTRING.
        select single * into WA_ZTICAUSER
        from ZTICAUSER.
        if sy-subrc <> 0.
          clear WA_ZTICAUSER.
        endif.
    SURL = 'http://XXXXXYYYYY:8050/sap/xi/adapter_plain?'.
        CONCATENATE SURL
         'namespace=' 'http%3A//XXXX.com/corp/sapbw/fi/ica/xi111fn1'
                    '&interface=' 'IOA_ICA_ReconciliationReport'
                    '&service=' 'Send_ICA_ReconciliationReport'
                    '&party=' 'ICA_ManualUpload'
                    '&agency='
                    '&scheme='
                    '&QOS=EO&sap-user='  WA_ZTICAUSER-USERID
                    '&sap-password=' WA_ZTICAUSER-PTEXT
                    '&sap-client=' '060'
                    '&sap-language=EN'
                    INTO SURL.
    * Test of XML file.
    *    navigation->set_parameter( name = 'xmlstring'
    *                               value = xmlstring ).
    *    navigation->goto_page( 'XMLTest.xml' ).
    * Navigation Code
        RLENGTH = STRLEN( XMLSTRING ).
        CL_HTTP_CLIENT=>CREATE_BY_URL( EXPORTING URL    = SURL
                                   IMPORTING CLIENT = HTTP_CLIENT ).
        CALL METHOD HTTP_CLIENT->REQUEST->SET_HEADER_FIELD
          EXPORTING
            NAME  = 'Content-Type'
            VALUE = 'text/xml; charset=utf-8'.
        CALL METHOD HTTP_CLIENT->REQUEST->SET_HEADER_FIELD
          EXPORTING
            NAME  = '~request_method'
            VALUE = 'POST'.
        CALL METHOD HTTP_CLIENT->REQUEST->SET_CDATA
          EXPORTING
            DATA   = XMLSTRING
            OFFSET = 0
            LENGTH = RLENGTH.
        HTTP_CLIENT->SEND( ).
        HTTP_CLIENT->RECEIVE( ).
        HTTP_CLIENT->RESPONSE->GET_STATUS( IMPORTING CODE = RLENGTH ).
        XMLSTRING = HTTP_CLIENT->RESPONSE->GET_CDATA( ).
        HTTP_CLIENT->CLOSE( ).
        IF RLENGTH = '200'.
          STRERROR = C_SUCCESS.
    * Update the information into the Table
          TRANSLATE SOURCE_SYSTEM_ID TO UPPER CASE.
          CONDENSE SOURCE_SYSTEM_ID.
          USERID1 = USERID.
          TRANSLATE USERID1 TO UPPER CASE.
          CONDENSE USERID1.
          CALL FUNCTION 'ZFM_BSP_ICA_UPLOAD'
            EXPORTING
              IV_SOURCE      = SOURCE_SYSTEM_ID
              IV_USERID      = USERID1
              IV_TYPE        = TYPE
    *          IV_UPLOAD_DATE = SY-DATUM
    *          IV_UPLOAD_TIME = SY-UZEIT
            IMPORTING
              R_CODE         = R_CODE.
        ELSE.
          STRERROR = C_ERROR4.
        ENDIF.
      ENDIF.
    ENDIF.
    Message was edited by: Mandar Shete

  • Executing HTTP Request from ABAP

    Hi Experts,
    I am trying to fill & submit an http form through abap using CL_HTTP_CLIENT class methods "request". here is my code:-
    DATA: client TYPE REF TO if_http_client.
    Create Client-Object
    CALL METHOD CL_HTTP_CLIENT=>CREATE_BY_URL
      EXPORTING
        url                = url_string
      IMPORTING
        CLIENT             = client
      EXCEPTIONS
        ARGUMENT_NOT_FOUND = 1
        PLUGIN_NOT_ACTIVE  = 2
        INTERNAL_ERROR     = 3
        others             = 4.
    IF sy-subrc <> 0.
      WRITE: / 'Client Object could not be created. SUBRC=', sy-subrc.
      EXIT.
    ENDIF.
    Set Header Field of request
    CALL METHOD client->request->if_http_entity~set_header_field
      EXPORTING
        name  = '~request_enctype'
        value = 'multipart/form-data'.
    CALL METHOD client->request->if_http_entity~set_header_field
      EXPORTING
        name  = '~request_method'
        value = 'POST'.
    try posting form fields
    CALL METHOD client->request->if_http_entity~set_form_field
      EXPORTING
        name  = 'datasource'
        value = 'GSAPO'.
    CALL METHOD client->request->if_http_entity~set_form_field
      EXPORTING
        name  = 'feedtype'
        value = 'full'.
    CALL METHOD client->request->if_http_entity~set_form_field
      EXPORTING
        name  = 'data'
        value = xml_string.
    CALL METHOD client->send
    EXPORTING
       TIMEOUT                    = CLIENT->CO_TIMEOUT_INFINITE
      EXCEPTIONS
        http_communication_failure = 1
        http_invalid_state         = 2
        http_processing_failed     = 3
        http_invalid_timeout       = 4
        OTHERS                     = 5
    IF sy-subrc <> 0.
      WRITE: / 'Request could not be sent - communication error. SUBRC=',
                                                                 sy-subrc.
      EXIT.
    ENDIF.
    Receive Response
    CALL METHOD client->receive
      EXCEPTIONS
        http_communication_failure = 1
        http_invalid_state         = 2
        http_processing_failed     = 3
        OTHERS                     = 4.
    IF sy-subrc <> 0.
      WRITE: 'Response not obtained - communication error SUBRC = ' ,
    sy-subrc.
      EXIT.
    ENDIF.
    Close HTTP connection
    CALL METHOD client->close
      EXCEPTIONS
        http_invalid_state = 1
        OTHERS             = 2.
    IF sy-subrc <> 0.
      WRITE 'HTTP connection in undefined state'.
      EXIT.
    ENDIF.
    *End of code.
    The problem here is I am getting exception "http_connection_failed" in recieve method.
    Can any body help me out.
    Thanks in advance.
    Madhu.

    is the http destination within intranet or internet? do you connect to internet via proxy server?
    Raja

  • Notes on using Object  oriented concept in ABAP

    Hi ,
    I want somes notes on how to use Object  oriented concept in ABAP.
    Thanks in advance.
    Chetan

    Hi, this may help you
    OOPs ABAP uses Classes and Interfaces which uses Methods and events.
    If you have Java skills it is advantage for you.
    There are Local classes as well as Global Classes.
    Local classes we can work in SE38 straight away.
    But mostly it is better to use the Global classes.
    Global Classes or Interfaces are to be created in SE24.
    SAP already given some predefined classes and Interfaces.
    This OOPS concepts very useful for writing BADI's also.
    So first create a class in SE 24.
    Define attributes, Methods for that class.
    Define parameters for that Method.
    You can define event handlers also to handle the messages.
    After creation in each method write the code.
    Methods are similar to ABAP PERFORM -FORM statements.
    After the creation of CLass and methods come to SE38 and create the program.
    In the program create a object type ref to that class and with the help of that Object call the methods of that Class and display the data.
    Example:
    REPORT sapmz_hf_alv_grid .
    Type pool for icons - used in the toolbar
    TYPE-POOLS: icon.
    TABLES: zsflight.
    To allow the declaration of o_event_receiver before the
    lcl_event_receiver class is defined, decale it as deferred in the
    start of the program
    CLASS lcl_event_receiver DEFINITION DEFERRED.
    G L O B A L I N T E R N A L T A B L E S
    *DATA: gi_sflight TYPE STANDARD TABLE OF sflight.
    To include a traffic light and/or color a line the structure of the
    table must include fields for the traffic light and/or the color
    TYPES: BEGIN OF st_sflight.
    INCLUDE STRUCTURE zsflight.
    Field for traffic light
    TYPES: traffic_light TYPE c.
    Field for line color
    types: line_color(4) type c.
    TYPES: END OF st_sflight.
    TYPES: tt_sflight TYPE STANDARD TABLE OF st_sflight.
    DATA: gi_sflight TYPE tt_sflight.
    G L O B A L D A T A
    DATA: ok_code LIKE sy-ucomm,
    Work area for internal table
    g_wa_sflight TYPE st_sflight,
    ALV control: Layout structure
    gs_layout TYPE lvc_s_layo.
    Declare reference variables to the ALV grid and the container
    DATA:
    go_grid TYPE REF TO cl_gui_alv_grid,
    go_custom_container TYPE REF TO cl_gui_custom_container,
    o_event_receiver TYPE REF TO lcl_event_receiver.
    DATA:
    Work area for screen 200
    g_screen200 LIKE zsflight.
    Data for storing information about selected rows in the grid
    DATA:
    Internal table
    gi_index_rows TYPE lvc_t_row,
    Information about 1 row
    g_selected_row LIKE lvc_s_row.
    C L A S S E S
    CLASS lcl_event_receiver DEFINITION.
    PUBLIC SECTION.
    METHODS:
    handle_toolbar FOR EVENT toolbar OF cl_gui_alv_grid
    IMPORTING
    e_object e_interactive,
    handle_user_command FOR EVENT user_command OF cl_gui_alv_grid
    IMPORTING e_ucomm.
    ENDCLASS.
    CLASS lcl_event_receiver IMPLEMENTATION
    CLASS lcl_event_receiver IMPLEMENTATION.
    METHOD handle_toolbar.
    Event handler method for event toolbar.
    CONSTANTS:
    Constants for button type
    c_button_normal TYPE i VALUE 0,
    c_menu_and_default_button TYPE i VALUE 1,
    c_menu TYPE i VALUE 2,
    c_separator TYPE i VALUE 3,
    c_radio_button TYPE i VALUE 4,
    c_checkbox TYPE i VALUE 5,
    c_menu_entry TYPE i VALUE 6.
    DATA:
    ls_toolbar TYPE stb_button.
    Append seperator to the normal toolbar
    CLEAR ls_toolbar.
    MOVE c_separator TO ls_toolbar-butn_type..
    APPEND ls_toolbar TO e_object->mt_toolbar.
    Append a new button that to the toolbar. Use E_OBJECT of
    event toolbar. E_OBJECT is of type CL_ALV_EVENT_TOOLBAR_SET.
    This class has one attribute MT_TOOLBAR which is of table type
    TTB_BUTTON. The structure is STB_BUTTON
    CLEAR ls_toolbar.
    MOVE 'CHANGE' TO ls_toolbar-function.
    MOVE icon_change TO ls_toolbar-icon.
    MOVE 'Change flight' TO ls_toolbar-quickinfo.
    MOVE 'Change' TO ls_toolbar-text.
    MOVE ' ' TO ls_toolbar-disabled.
    APPEND ls_toolbar TO e_object->mt_toolbar.
    ENDMETHOD.
    METHOD handle_user_command.
    Handle own functions defined in the toolbar
    CASE e_ucomm.
    WHEN 'CHANGE'.
    PERFORM change_flight.
    LEAVE TO SCREEN 0.
    ENDCASE.
    ENDMETHOD.
    ENDCLASS.
    S T A R T - O F - S E L E C T I O N.
    START-OF-SELECTION.
    SET SCREEN '100'.
    *& Module USER_COMMAND_0100 INPUT
    MODULE user_command_0100 INPUT.
    CASE ok_code.
    WHEN 'EXIT'.
    LEAVE TO SCREEN 0.
    ENDCASE.
    ENDMODULE. " USER_COMMAND_0100 INPUT
    *& Module STATUS_0100 OUTPUT
    MODULE status_0100 OUTPUT.
    DATA:
    For parameter IS_VARIANT that is sued to set up options for storing
    the grid layout as a variant in method set_table_for_first_display
    l_layout TYPE disvariant,
    Utillity field
    l_lines TYPE i.
    After returning from screen 200 the line that was selected before
    going to screen 200, should be selected again. The table gi_index_rows
    was the output table from the GET_SELECTED_ROWS method in form
    CHANGE_FLIGHT
    DESCRIBE TABLE gi_index_rows LINES l_lines.
    IF l_lines > 0.
    CALL METHOD go_grid->set_selected_rows
    EXPORTING
    it_index_rows = gi_index_rows.
    CALL METHOD cl_gui_cfw=>flush.
    REFRESH gi_index_rows.
    ENDIF.
    Read data and create objects
    IF go_custom_container IS INITIAL.
    Read data from datbase table
    PERFORM get_data.
    Create objects for container and ALV grid
    CREATE OBJECT go_custom_container
    EXPORTING container_name = 'ALV_CONTAINER'.
    CREATE OBJECT go_grid
    EXPORTING
    i_parent = go_custom_container.
    Create object for event_receiver class
    and set handlers
    CREATE OBJECT o_event_receiver.
    SET HANDLER o_event_receiver->handle_user_command FOR go_grid.
    SET HANDLER o_event_receiver->handle_toolbar FOR go_grid.
    Layout (Variant) for ALV grid
    l_layout-report = sy-repid. "Layout fo report
    Setup the grid layout using a variable of structure lvc_s_layo
    Set grid title
    gs_layout-grid_title = 'Flights'.
    Selection mode - Single row without buttons
    (This is the default mode
    gs_layout-sel_mode = 'B'.
    Name of the exception field (Traffic light field) and the color
    field + set the exception and color field of the table
    gs_layout-excp_fname = 'TRAFFIC_LIGHT'.
    gs_layout-info_fname = 'LINE_COLOR'.
    LOOP AT gi_sflight INTO g_wa_sflight.
    IF g_wa_sflight-paymentsum < 100000.
    Value of traffic light field
    g_wa_sflight-traffic_light = '1'.
    Value of color field:
    C = Color, 6=Color 1=Intesified on, 0: Inverse display off
    g_wa_sflight-line_color = 'C610'.
    ELSEIF g_wa_sflight-paymentsum => 100000 AND
    g_wa_sflight-paymentsum < 1000000.
    g_wa_sflight-traffic_light = '2'.
    ELSE.
    g_wa_sflight-traffic_light = '3'.
    ENDIF.
    MODIFY gi_sflight FROM g_wa_sflight.
    ENDLOOP.
    Grid setup for first display
    CALL METHOD go_grid->set_table_for_first_display
    EXPORTING i_structure_name = 'SFLIGHT'
    is_variant = l_layout
    i_save = 'A'
    is_layout = gs_layout
    CHANGING it_outtab = gi_sflight.
    *-- End of grid setup -
    Raise event toolbar to show the modified toolbar
    CALL METHOD go_grid->set_toolbar_interactive.
    Set focus to the grid. This is not necessary in this
    example as there is only one control on the screen
    CALL METHOD cl_gui_control=>set_focus EXPORTING control = go_grid.
    ENDIF.
    ENDMODULE. " STATUS_0100 OUTPUT
    *& Module USER_COMMAND_0200 INPUT
    MODULE user_command_0200 INPUT.
    CASE ok_code.
    WHEN 'EXIT200'.
    LEAVE TO SCREEN 100.
    WHEN'SAVE'.
    PERFORM save_changes.
    ENDCASE.
    ENDMODULE. " USER_COMMAND_0200 INPUT
    *& Form get_data
    FORM get_data.
    Read data from table SFLIGHT
    SELECT *
    FROM zsflight
    INTO TABLE gi_sflight.
    ENDFORM. " load_data_into_grid
    *& Form change_flight
    Reads the contents of the selected row in the grid, ans transfers
    the data to screen 200, where it can be changed and saved.
    FORM change_flight.
    DATA:l_lines TYPE i.
    REFRESH gi_index_rows.
    CLEAR g_selected_row.
    Read index of selected rows
    CALL METHOD go_grid->get_selected_rows
    IMPORTING
    et_index_rows = gi_index_rows.
    Check if any row are selected at all. If not
    table gi_index_rows will be empty
    DESCRIBE TABLE gi_index_rows LINES l_lines.
    IF l_lines = 0.
    CALL FUNCTION 'POPUP_TO_DISPLAY_TEXT'
    EXPORTING
    textline1 = 'You must choose a line'.
    EXIT.
    ENDIF.
    Read indexes of selected rows. In this example only one
    row can be selected as we are using gs_layout-sel_mode = 'B',
    so it is only ncessary to read the first entry in
    table gi_index_rows
    LOOP AT gi_index_rows INTO g_selected_row.
    IF sy-tabix = 1.
    READ TABLE gi_sflight INDEX g_selected_row-index INTO g_wa_sflight.
    ENDIF.
    ENDLOOP.
    Transfer data from the selected row to screenm 200 and show
    screen 200
    CLEAR g_screen200.
    MOVE-CORRESPONDING g_wa_sflight TO g_screen200.
    LEAVE TO SCREEN '200'.
    ENDFORM. " change_flight
    *& Form save_changes
    Changes made in screen 200 are written to the datbase table
    zsflight, and to the grid table gi_sflight, and the grid is
    updated with method refresh_table_display to display the changes
    FORM save_changes.
    DATA: l_traffic_light TYPE c.
    Update traffic light field
    Update database table
    MODIFY zsflight FROM g_screen200.
    Update grid table , traffic light field and color field.
    Note that it is necessary to use structure g_wa_sflight
    for the update, as the screen structure does not have a
    traffic light field
    MOVE-CORRESPONDING g_screen200 TO g_wa_sflight.
    IF g_wa_sflight-paymentsum < 100000.
    g_wa_sflight-traffic_light = '1'.
    C = Color, 6=Color 1=Intesified on, 0: Inverse display off
    g_wa_sflight-line_color = 'C610'.
    ELSEIF g_wa_sflight-paymentsum => 100000 AND
    g_wa_sflight-paymentsum < 1000000.
    g_wa_sflight-traffic_light = '2'.
    clear g_wa_sflight-line_color.
    ELSE.
    g_wa_sflight-traffic_light = '3'.
    clear g_wa_sflight-line_color.
    ENDIF.
    MODIFY gi_sflight INDEX g_selected_row-index FROM g_wa_sflight.
    Refresh grid
    CALL METHOD go_grid->refresh_table_display.
    CALL METHOD cl_gui_cfw=>flush.
    LEAVE TO SCREEN '100'.
    ENDFORM. " save_changes
    chk this blog
    /people/vijaybabu.dudla/blog/2006/07/21/topofpage-in-alv-using-clguialvgrid
    Reward if helpfull.
    Regards Madhu.

  • HTTP POST from SAP to an external server

    Experts.
    I have a XML file encased in MIME and SOAP format. Essentially it's a .xml file.
    I need to post this to an external server (have the IP address and logon credentials) using http post functionality.
    Can this be accomplished in SAP using ABAP, Function module? I need to post the entire file.
    If anyone has done this, can you please post the steps needed?
    Thank you so much.
    Raj

    Hi Raj,
    a good starting point for you would be the SAP Help. [Here|http://help.sap.com/saphelp_nw04/helpdata/en/1f/93163f9959a808e10000000a114084/frameset.htm] is some sample code of how to make a HTTP call from ABAP.
    Cheers
    Graham Robbo
    Edited by: Graham Robinson on Oct 28, 2009 2:44 PM

  • Http post from an application with file attachment

    Hi ! I didn't know where else to post this message...
    I'm trying to make a HTTP POST from an application and upload a file with it. I have no problems with the posting, just that I haven't got any ideas how to get the file uploaded as well. I've been reading loads of examples regarding the topic, and searching older posts the forum here, without any help.
    Here's the method i'm using:
                   // open connections
                  URL url = new URL ("TheURL");
                   URLConnection urlConn = url.openConnection();
                              // We do input & output, without caching
                   urlConn.setDoInput (true);
                   urlConn.setDoOutput (true);
                   urlConn.setUseCaches (false);
                              // multipart/form-data because we want to upload a file
                     urlConn.setRequestProperty ("Content-Type", "multipart/form-data");
                  // Open output stream
                     DataOutputStream printout = new DataOutputStream (urlConn.getOutputStream ());
                  // Set the actual content
                     String content = "upfile=" + System.getProperty("user.dir") + "\\file.ext&";
                       content += "other_key-value_pairs";
                  // write the data to stream, and flush it.
                     printout.writeBytes (URLEncoder.encode(content));
                   printout.flush ();
                   printout.close ();
                   // Get the response.
                     DataInputStream input = new DataInputStream (urlConn.getInputStream());
                   FileOutputStream fos=new FileOutputStream("postto.txt");
                   String str;
                     BufferedReader bufr = new BufferedReader(new InputStreamReader(input));
                  // Write response to outputfile
                     while (null != ((str = bufr.readLine()))) {
                         if (str.length() >0) {
                         fos.write(str.getBytes());
                         fos.write(new String("\n").getBytes());
                   input.close ();Now, the response here I get from the url i'm posting to is "Failure, no data-file". I've tried many diff methods of writing the file to the stream, but always get the same result.
    I need to file attached like it would be when using a HTML form's <input type="file">.
    Please help ! This is getting really urgent !

    String content = "upfile=" + System.getProperty("user.dir") + "\\file.ext&";
    content += "other_key-value_pairs";
    printout.writeBytes (URLEncoder.encode(content));
    printout.flush ();
    printout.close ();Actually, what this does is create a request like:
    GET /path/to/file/script.language?upfile=/home/user/file.ext&other=params HTTP/1.1
    Content-Type: multipart/form-data
    -- And other HTTP params --
    The file is not actually appended to the request.
    I really don't know how Java handles the file upload, but you could do it by hand, like so:
    public static void doFileUpload(String url, String filename, Hashtable params) throws IOException {
        // Construct the request
        String boundary = "----------------------mUlTiPaRtBoUnDaRy";
        String request_head = "POST " + url + " HTTP/1.0\r\n" +
                                         "Content-type: multipart/form-data; boundary=" + boundary + "\r\n";
        String request_body = boundary + "\r\n\r\nContent-disposition: form-data; name=\"upload\"" +
                                         "\r\n\r\n";
        BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(filename)));
        int b = -1;
        while((b = in.read()) != -1) {
             request_body += (char)b;
        in.close();
        Enumeration keys = params.keys();
        while(keys.hasMoreElements()) {
            String key = keys.nextElement();
            requst_body += "\r\n" + boundary + "\r\n\r\nContent-type: form-data; name=\"key\"\r\n" +
                                    (String)params.get(key);
        request_body += "\r\n" + boundary + "--\r\n";
        int length = request_head.length() + request_body.length() + "Content-length: \r\n";
        String req_length = "Content-length: " + (length + new String("" + length).length()) + "\r\n";
        Socket socket = new Socket(url,80);
        PrintStream stream = socket.getOutputStream();
        stream.print(request_head + req_length + req_body);
        // And now an option to read the response, I will omit that...   
    }Note: I have not tested this code, just wrote it up out of memory. If it does not work, it will propably need some small fixes.
    Tuomas Rinta

  • Adding color to a row in alv grid not using object oriented.

    Hello Gurus.
    I want to display a row in  color in alv grid using normal alv,  not by using object oriented programming.
    I am having one of the field say spart ie division in internal table itab.
    The spart has values like 12 , 45, 67, 68 ,88 ,99.
    when ever spart is 12 i want to display that row in color format. Here this table is sorted by mblnr so if 1st record is 12 then may be 50 th record will be 12. so when where the record contains the value has 12 then that row should be displayed in color. So please tell me how to do it. Previously i posted the same question but i got is by using object oriented. so please tell me how to do it without using object oriented.
    Thanks for all the replies.

    Check this example code.
    report zrich_0004
           no standard page heading.
    type-pools slis.
    data: fieldcat type slis_t_fieldcat_alv.
    data: begin of imara occurs 0,
          matnr type mara-matnr,
          mtart type mara-mtart,
          maktx type makt-maktx,
          color_line(4) type c,
          tcolor type slis_t_specialcol_alv,  "cell
          end of imara.
    data: xcolor type slis_specialcol_alv.
    start-of-selection.
      perform get_data.
      perform write_report.
    *  Get_Data
    form get_data.
      imara-matnr = 'ABC'.
      imara-mtart = 'ZCFG'.
      imara-maktx = 'This is description for ABC'.
      append imara.
      imara-matnr = 'DEF'.
      imara-mtart = 'ZCFG'.
      imara-maktx = 'This is description for DEF'.
      append imara.
      imara-matnr = 'GHI'.
      imara-mtart = 'ZCFG'.
      imara-maktx = 'This is description for GHI'.
      append imara.
      loop at imara.
        if sy-tabix = 1.
          imara-color_line = 'C410'.   " color line
        endif.
        if sy-tabix = 2.          "color CELL
          clear xcolor.
          xcolor-fieldname = 'MTART'.
          xcolor-color-col = '3'.
          xcolor-color-int = '1'. "Intensified on/off
          xcolor-color-inv = '0'.
          append xcolor to imara-tcolor.
        endif.
        modify imara.
      endloop.
    endform.
    *  WRITE_REPORT
    form write_report.
      data: layout type  slis_layout_alv.
      layout-coltab_fieldname = 'TCOLOR'.
      layout-info_fieldname = 'COLOR_LINE'.
      perform build_field_catalog.
    * CALL ABAP LIST VIEWER (ALV)
      call function 'REUSE_ALV_GRID_DISPLAY'
           exporting
                is_layout   = layout
                it_fieldcat = fieldcat
           tables
                t_outtab    = imara.
    endform.
    * BUILD_FIELD_CATALOG
    form build_field_catalog.
      data: fc_tmp type slis_t_fieldcat_alv with header line.
      clear: fieldcat. refresh: fieldcat.
      clear: fc_tmp.
      fc_tmp-reptext_ddic    = 'Material Number'.
      fc_tmp-fieldname  = 'MATNR'.
      fc_tmp-tabname   = 'IMARA'.
      fc_tmp-outputlen  = '18'.
      append fc_tmp to fieldcat.
      clear: fc_tmp.
      fc_tmp-reptext_ddic    = 'Material Type'.
      fc_tmp-fieldname  = 'MTART'.
      fc_tmp-tabname   = 'IMARA'.
      fc_tmp-outputlen  = '4'.
      append fc_tmp to fieldcat.
      clear: fc_tmp.
      fc_tmp-reptext_ddic    = 'Material'.
      fc_tmp-fieldname  = 'MAKTX'.
      fc_tmp-tabname   = 'IMARA'.
      fc_tmp-outputlen  = '40'.
      fc_tmp-emphasize = 'C610'.   " color column
      append fc_tmp to fieldcat.
    endform.
    Regards,
    Rich Heilman

  • What are object oriented methods?

    i dont seem to understand the term object oriented methods. i know that it is a technology which encompasses a body of methods,processes, and tools used to construct software systems from obejcts. i know that i provides a unifying paradigm for the three traditional phases of software development: analysis,design and implementation. so how do i get more information on this. i mean this is very limited information i have on my hands. how do i explain in detail about the major features of object oriented methods and their major benefits. is there a place where i can find out about it? please help me out?

    Object-Oriented Programming Concepts
    Object-oriented language basics
    Don't Fear the OOP

  • How to display horizontal line in top-of-page by using object oriented ALV?

    How to display horizontal line in top-of-page by using object oriented ALV.
    I am created top-of-page in object oriented alv.
    But not be successes in showing horizontal line in it.
    Can any one pls give solution for this..
    Thanks and regards..

    Hi
    Try like this
    data: gt_list_top_of_page type slis_t_listheader. " Top of page text. 
    Initialization. 
    perform comment_build using gt_list_top_of_page[]. 
    form top_of_page. 
    * Note to self: the gif must be loaded into transaction OAOR with 
    * classname 'PICTURES' AND TYPE 'OT' to work with ALV GRID Functions. 
    * I Loaded NOVALOGO2 into system. 
    call function 'REUSE_ALV_COMMENTARY_WRITE' 
         exporting 
    * I_LOGO = 'NOVALOGO2' 
    * i_logo = 'ENJOYSAP_LOGO' 
             it_list_commentary = gt_list_top_of_page. 
    endform. " TOP_OF_PAGE 
    form comment_build using e04_lt_top_of_page type slis_t_listheader. 
    data: ls_line type slis_listheader. 
          clear ls_line. 
          ls_line-typ = 'A'. 
          ls_line-info = 'Special'(001). 
          fgrant = xgrant. 
          concatenate ls_line-info fgrant 
          'Stock Option Report to the board'(002) 
                 into ls_line-info separated by space. 
                        condense ls_line-info. 
          append ls_line to e04_lt_top_of_page. 
    endform. " COMMENT_BUILD
    Use following syntex for footer print in alv:
    * For End of Page
    form END_OF_PAGE.
      data: listwidth type i,
            ld_pagepos(10) type c,
            ld_page(10)    type c.
      write: sy-uline(50).
      skip.
      write:/40 'Page:', sy-pagno .
    endform.
    *  For End of Report
    form END_OF_LIST.
      data: listwidth type i,
            ld_pagepos(10) type c,
            ld_page(10)    type c.
      skip.
      write:/40 'Page:', sy-pagno .
    endform.
    check this link
    http://abapprogramming.blogspot.com/
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/5dc3e690-0201-0010-1ebf-b85b3bed962d
    Changing width of a custom container dynamically
    Display Page numbers in ALV
    Insert picture in selection screen.
    Logo in OO ALV Grid
    Reward all helpfull answers
    Regards
    Pavan

  • Calling Java API from ABAP using JCo (Part 2)

    Hello,
    This is an additional question to thread Calling Java API from ABAP using JCo
    Has anyone managed to get the input parameter value
    input.getString("REQUTEXT")
    that is being passed from ABAP?
    If yes, what kind of setting you need to do? Because when I execute, it has no value.
    Thus, the below ECHOTEXT parameter returns blank value:
    output.setValue(input.getString("REQUTEXT"),"ECHOTEXT");
    When I debug by printing the below line, the input XML is indeed without value:
    System.out.println(input.toXML());
    Anybody knows how to pass input variable from ABAP to JAVA using JCo?
    rgs,
    hiroshi

    Hallo Hiroshi,
    as far as I can see, you are doing it the right way. The problem might be that the ABAP program does not fill in this parameter because something went wrong in the SAP System.
    Have you tried setting a breakpoint (an HTTP session - remote breakpoint) and tried checking step by step if the value is being processed and put into the REQUTEXT field?
    Bye,
    Sameer

  • How to capture index/row no of row in table using object oriented alv.

    i have a table with many fields. i have an alv grid table displayed using object oriented alv. when i double click on a record, i call another screen. there i want to display the record number. eg, if i doubleclick on the third row, i will go to next screen and display 3 there.
    please let me know how it is done as it is urgent.
    thanks in advance.

    Hi,
    Use the following code to get rowno.
    CLASS lcl_grid_events DEFINITION DEFERRED.
    DATA:
      grid1_events      TYPE REF TO lcl_grid_events.
    CLASS lcl_grid_events DEFINITION.
      PUBLIC SECTION.
        METHODS:
          dbclk
           FOR EVENT double_click  OF cl_gui_alv_grid
           IMPORTING e_row
                     e_column
                     es_row_no.
    ENDCLASS.                    "lcl_grid_events DEFINITION
    CLASS lcl_grid_events IMPLEMENTATION.
      METHOD dbclk.
    *access e_row variable, which contains the record no.
      ENDMETHOD.                    "dbclk
    ENDCLASS.                    "lcl_grid
    write the following code after method call of set_table_for_first_display
        CREATE OBJECT grid1_events.
        SET HANDLER grid1_events->dbclk
                    FOR grid1.
    reward point if useful.

  • Grid using Object Oriented View

    Can anyone send me program for grid using object oriented view.

    hi Sandeep,
    please look at this code
    REPORT Z_PICK_LIST .
    TABLES: RESB.
    SELECTION-SCREEN BEGIN OF BLOCK BL1 WITH FRAME TITLE TEXT-BL1.
    SELECT-OPTIONS: S_WERKS FOR RESB-WERKS," Plant
    S_AUFNR FOR RESB-AUFNR," Order number
    S_BDTER FOR RESB-BDTER." Req. date
    SELECTION-SCREEN END OF BLOCK BL1.
    PARAMETERS: P_VARI LIKE DISVARIANT-VARIANT DEFAULT '/STANDARD'.
    DATA: BEGIN OF OUT OCCURS 10,
    AUFNR LIKE RESB-AUFNR, " Order number
    MATNR LIKE RESB-MATNR, " Material
    BDMNG LIKE RESB-BDMNG, " Requirements in UM
    MEINS LIKE RESB-MEINS, " Unit of Measure (UM)
    ERFMG LIKE RESB-ERFMG, " Requirements in UE
    ERFME LIKE RESB-ERFME, " Unit of Entry (UE)
    MAKTX LIKE MAKT-MAKTX, " Mat. description
    END OF OUT.
    INCLUDE Z_ALV_VARIABLES.
    INITIALIZATION.
    REPNAME = SY-REPID.
    PERFORM INITIALIZE_FIELDCAT USING FIELDTAB[].
    PERFORM BUILD_EVENTTAB USING EVENTS[].
    PERFORM BUILD_COMMENT USING HEADING[].
    PERFORM INITIALIZE_VARIANT.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_VARI.
    PERFORM F4_FOR_VARIANT.
    AT SELECTION-SCREEN.
    PERFORM PAI_OF_SELECTION_SCREEN.
    START-OF-SELECTION.
    PERFORM GET_ORDERS.
    PERFORM GET_MATERIAL_DESCRIPTION.
    END-OF-SELECTION.
    PERFORM BUILD_LAYOUT USING LAYOUT.
    PERFORM BUILD_PRINT USING PRINTS.
    PERFORM WRITE_USING_ALV.
    FORM INITIALIZE_FIELDCAT *
    --> P_TAB *
    FORM INITIALIZE_FIELDCAT USING P_TAB TYPE SLIS_T_FIELDCAT_ALV.
    DATA: CAT TYPE SLIS_FIELDCAT_ALV.
    CLEAR CAT.
    ENDFORM. " INITIALIZE_FIELDCAT
    *& Form GET_ORDERS
    text
    FORM GET_ORDERS.
    SELECT AUFNR MATNR BDMNG MEINS ERFMG ERFME
    FROM RESB
    APPENDING TABLE OUT
    WHERE XLOEK EQ SPACE " deletion indicator
    AND XWAOK EQ 'X' " goods movement indicator
    AND WERKS IN S_WERKS " plant
    AND BDTER IN S_BDTER " req. date
    AND AUFNR IN S_AUFNR. " pr. order
    ENDFORM. " GET_ORDERS
    *& Form GET_MATERIAL_DESCRIPTION
    text
    FORM GET_MATERIAL_DESCRIPTION.
    SORT OUT BY MATNR.
    LOOP AT OUT.
    SELECT SINGLE MAKTX
    INTO OUT-MAKTX
    FROM MAKT
    WHERE MATNR EQ OUT-MATNR
    AND SPRAS EQ 'EN'.
    MODIFY OUT.
    ENDLOOP.
    SORT OUT BY AUFNR MATNR.
    ENDFORM. " GET_MATERIAL_DESCRIPTION
    FORM TOP_OF_PAGE *
    FORM TOP_OF_PAGE.
    DATA: L_POS TYPE P.
    first line
    WRITE:/ TEXT-001. " Plant:
    IF S_WERKS-HIGH NE SPACE.
    WRITE: S_WERKS-LOW, TEXT-TO1, S_WERKS-HIGH.
    ELSEIF S_WERKS-LOW NE SPACE.
    LOOP AT S_WERKS.
    WRITE: S_WERKS-LOW.
    ENDLOOP.
    ELSEIF S_WERKS-LOW EQ SPACE.
    WRITE: TEXT-ALL.
    ENDIF.
    L_POS = ( SY-LINSZ DIV 2 ) - ( STRLEN( TEXT-TIT ) DIV 2 ).
    POSITION L_POS. WRITE: TEXT-TIT.
    L_POS = SY-LINSZ - 20.
    POSITION L_POS. WRITE: TEXT-011, SY-UNAME RIGHT-JUSTIFIED. " User:
    second line
    WRITE:/ TEXT-002. " Order:
    IF S_AUFNR-HIGH NE SPACE.
    WRITE: S_AUFNR-LOW, TEXT-TO1, S_AUFNR-HIGH.
    ELSEIF S_AUFNR-LOW NE SPACE.
    LOOP AT S_AUFNR.
    WRITE: S_AUFNR-LOW.
    ENDLOOP.
    ELSEIF S_AUFNR-LOW EQ SPACE.
    WRITE: TEXT-ALL.
    ENDIF.
    L_POS = SY-LINSZ - 20.
    POSITION L_POS. WRITE: TEXT-012,SY-DATUM. " Date:
    third line
    WRITE:/ TEXT-003. " Req. Date:
    IF S_BDTER-HIGH(1) NE '0'.
    WRITE: S_BDTER-LOW, TEXT-TO1, S_BDTER-HIGH.
    ELSEIF S_BDTER-LOW(1) NE '0'.
    LOOP AT S_BDTER.
    WRITE: S_BDTER-LOW.
    ENDLOOP.
    ELSEIF S_BDTER-LOW(1) EQ '0'.
    WRITE: TEXT-ALL.
    ENDIF.
    L_POS = SY-LINSZ - 20.
    POSITION L_POS. WRITE: TEXT-013, SY-PAGNO. " Page:
    ENDFORM. " TOP_OF_PAGE
    FORM END_OF_LIST *
    FORM END_OF_LIST.
    DATA: L_POS TYPE P.
    ULINE.
    WRITE:/ '|', TEXT-021. " Delivered by:
    L_POS = SY-LINSZ DIV 2.
    POSITION L_POS. WRITE: '|', TEXT-031. " Received by:
    L_POS = SY-LINSZ.
    POSITION L_POS. WRITE: '|'.
    WRITE:/ '|'.
    L_POS = SY-LINSZ DIV 2.
    POSITION L_POS. WRITE: '|'.
    L_POS = SY-LINSZ.
    POSITION L_POS. WRITE: '|'.
    ULINE.
    WRITE:/ '|', TEXT-012. " Date:
    L_POS = SY-LINSZ DIV 2.
    POSITION L_POS. WRITE: '|', TEXT-012. " Date:
    L_POS = SY-LINSZ.
    POSITION L_POS. WRITE: '|'.
    WRITE:/ '|'.
    L_POS = SY-LINSZ DIV 2.
    POSITION L_POS. WRITE: '|'.
    L_POS = SY-LINSZ.
    POSITION L_POS. WRITE: '|'.
    ULINE.
    ENDFORM. " END_OF_LIST
    *& Form WRITE_USING_ALV
    text
    FORM WRITE_USING_ALV.
    Look this code*****
    CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
    EXPORTING
    I_PROGRAM_NAME = REPNAME
    I_INTERNAL_TABNAME = 'OUT'
    I_INCLNAME = REPNAME
    CHANGING
    CT_FIELDCAT = FIELDTAB.
    IF SY-SUBRC 0.
    WRITE: 'SY-SUBRC: ', SY-SUBRC,
    'REUSE_ALV_FIELDCATALOG_MERGE'.
    ENDIF.
    LOOk this code also.*********
    CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
    EXPORTING
    I_CALLBACK_PROGRAM = REPNAME
    i_callback_pf_status_set = 'PF_STATUS_SET'
    i_callback_user_command = 'USER_COMMAND'
    I_STRUCTURE_NAME = 'OUT'
    IS_LAYOUT = LAYOUT
    IT_FIELDCAT = FIELDTAB
    I_DEFAULT = 'A'
    I_SAVE = G_SAVE
    IS_VARIANT = G_VARIANT
    IT_EVENTS = EVENTS[]
    IS_PRINT = PRINTS
    TABLES
    T_OUTTAB = OUT.
    IF SY-SUBRC 0.
    WRITE: 'SY-SUBRC: ', SY-SUBRC, 'REUSE_ALV_LIST_DISPLAY'.
    ENDIF.
    ENDFORM. " WRITE_USING_ALV
    ***************report over***************
    HOPE THIS CODE HELPS U
    Reward if its useful.............
    thanks and regards
    suma sailaja

  • TOP-OF-PAGE using Object Oriented model

    Hi all,
    (1)  I hve a doubt reg the top-of-page using Object oriented concept . While iam creating the top-of-page iam using a class called ' cl_dd_document' , wht is the purpose of that class ?
    (2) I have displayed a text in the top-of-page container . I want to display another text in a new line in the same container below the first text . How can i do it . plz send me a sample code for it .
    Vighnesh ,

    1. this class cl_dd_document is used to define the properties of the text used in top of page...to change the fonts of texts , to add space between texts, to add a new line and so on..
    2.  to add new line , use this
    CALL METHOD document->new_line.

  • Explain an object-oriented method for a conversion between the E/R diagram

    Somebody can explain me with an example an object-oriented method for a conversion between the E/R diagram and a relational database schema.
    Thanks,

    Hello here are some tips regarding how to convert ERD into Relational objects.
    (1) One to many relationships:
    One to many relationships can be explained by following example.
    Take example of department and Employee. One employee can work in one department only but one department can have more then one employees. In one to many relationship Primary key of One side (here department table) goes to Many side as foreign key (here Employee table).
    (2) Many to Many relationships:
    Many to many relationships can be explained by following example.
    One student can take many subjects and one subject can be taken by more then one student.
    In this case one new table emerges which includes Primary keys of both the tables and establish composite primary key. e.g. here if PK of student is student_id and Pk of course is course_id then new table will emerge named (say) student_course with composite primary key of student_id and course_id (student_id and course_id are also foreign keys)
    (3) One to One:
    Example: A person can have only one tax file number and one tax file number can be allocated to only one person. In this case PK of any table can go to another table as foreign key.
    (4) Super class-sub class relationship:
    Example: person can be a man or woman. Such kinds of relationships are called super class- sub class relationship. There are many ways to convert such relationship into tables
    we can make one table for super class (eg Table Person) and we can put PK of super class in subclass as primary key (eg if person_id is pk of table person then it will go in both sub classes (man, woman) as Pk and it will also be foreign key of the super class (person)
    Note: This is just a way to solve super class relationships there are many other ways which you can choose.
    Thanks
    Ish

  • Shifting from procedural to object oriented

    Hi people,
    I've been programming in ABAP in a procedural fashion since I started, because that's the way I was taught. Now I want to slowly shift to object oriented development. I know and understand all object oriented concepts (please don't copy paste OOP explanations or links merely to get points). Problem is, in the projects i'm involved everything is done in the old fashion. There's no use of UML whatsoever. I believe it's very difficult to shift my mind to OOP (an already difficult task for someone programming procedural for years) if the analisys and design is not done with OO as the base, as additionally I have very little practical experience with OOP (using ALV classes and such). If every other programmer does things in procedural way, when the time comes to integrate programs, problems arise.
    I've been experimenting with OOP in my safe minisap at home, but in day to day work as pressure is put to finish programs on time, always procedural solutions come to mind.
    Do you have any advice on how to cope with this? Can you post your experience on this subject? Has someone gone through this same problems?
    Many thanks.

    Hello Alejandro
    When I started with object-oriented ABAP programming about 2 years ago I made horrible mistakes in my classes and interfaces. However, I have my lessons learnt from these mistakes and improved my skills and knowledge step by step.
    I have 3 recommendations for you:
    <b>(1) Start now!</b>
    Do not expect to develop perfect interfaces and classes from the very beginning. Understanding Object-Orientation takes its time.
    <b>(2) Start with simple objects.</b>
    Interfaces (or classes) can be used to define globally visible constants. Your first classes may contain only static methods. Yet while developing these "simple" objects you will get familiar with the class builder (SE24).
    <b>
    (3) Make heavy use of SAP standard classes.</b>
    Before creating your own class(es) make a comprehensive search for available standard classes (of course, if you are dealing with custom-developed business objects you have to create your own classes).
    For example, if you have to work with purchase orders have a look at the following classes:
    - CL_PO_HEADER_HANDLE_MM
    - CL_PO_ITEM_HANDLE_MM
    If you create an instance of CL_PO_HEADER_HANDLE_MM you will have thousands of coding lines at your fingertip (e.g. method IF_PURCHASE_ORDER_MMGET_DATA returns the header data, method IF_PURCHASE_ORDER_MMGET_ITEMS returns the  order items -> no need of coding, just CALLING).
    Finally, you may have a look at the following examples:
    <a href="https://wiki.sdn.sap.com/wiki/display/profile/2007/07/09/UnderstandingABAPObjects">Understanding ABAP Objects</a>
    <a href="https://wiki.sdn.sap.com/wiki/display/profile/2007/07/09/MessageHandling-FindingtheNeedleintheHaystack">Message Handling - Finding the Needle in the Haystack</a>
    <a href="https://wiki.sdn.sap.com/wiki/display/Snippets/UnifiedAccesstoAllHR+Infotypes">Unified Access to All HR Infotypes</a>
    Regards
      Uwe

Maybe you are looking for