Replace Values for a Col under a Table using Replace Function in Sql Query

Hi all
I have a Custom Table by Name RESP_TABLE which stores the Responsibility Names under the Column RESPONSIBILITY.
The Sample Value for this col is as follows :
PF <CNTRY> Gl Analyst <CCY>.
This <CNTRY> Stands for Country Short Name
and <CCY> Stands for Currency.
The <CNTRY> & <CCY> should be passed as a parameter at the run time.
Based on the value given at the run time it should change accordingly.
For example
PF <CNTRY> Gl Analyst <CCY>
<CNTRY> Value passed at runtime : BE
<CCY> Value passed at runtime : CAD
So the resulting value should be as follows :
PF BE Gl Analyst CAD.
I had already used the query given below :
SELECT REPLACE(RESPONSIBILITY,'<CNTRY>','&MARKET') FROM RESP_TABLE.
This works fine for Country Code alone but not for currency.
I need both the Country Code and Currency Code to be changed to the respective values given at the runtime.
Could anybody please help me on this ?
Regards
Nakul Venkataraman.

Hi Nakul,
Why not just adding another REPLACE to what you still have achieved? :)
Regards,
Guido

Similar Messages

  • DEFAULT a value for a filed from a table used in ABAP query

    I have used a field makt-spras in my infoset query and used it in my selection screen. Whenever I go into the transaction for the query and see the selection screen it always has 'EN' in the language key. Is there a way I can clear that . I dont want the selection screen to have anything wyhen I enter the transaction so that teh user can enter his or her own language and instead remove the work of removing the EN always . I would like to default it to blank space initially . In the query where can I do that as I dont see nay option to default it to space in the query for this field that is directly used form the table .
    Thanks

    Hi There,
    In the transaction SQ02 (for Infoset), click on the button Extras on the top and then in the Tabstrip that appears, you will have Code, click on that. After that from the drop down selection box, select Initialization even and write the code CLEAR makt-spras field.
    This should work.
    S.Dakshna Nagaratnam.
    Edited by: Dakshna Nagaratnam on May 22, 2009 7:25 PM

  • How to create a Matrix table using this data in SQL Query Analyzer

    Hello all,
    I have a problem while I am trying to represent my Sql Table namely table1 in Matrix form
    my table Format is
    city1 city2 Distance--------------------------------------------------------
    Mumbai Delhi 100
    Delhi Banaras 50
    Mumbai Rajasthan 70
    Banaras haryana 40
    Mumbai Mumbai 0
    784 entries
    there are 784 cities each having link to other
    Now i want my output as
    Mumbai Delhi Banaras haryana
    Mumbai 0 100 -- --
    Delhi 100 0 50 --
    Banaras
    haryana
    respective distance from one city to other should be shown
    final Matrix would be 784*784
    I am using SQL Query Analyser for this
    Please help me in this regard

    I'm pretty much certain that you don't want to do this in pure SQL. So that means that you want to do it with a reporting tool. I'm not familiar with SQL Query Analyzer, but if it is in fact a reporting tool you'll want to consult its documentation looking for the terms "pivot" or perhaps "cross tab."

  • ORA-01841 Error when value for date col is NULL in .dat (using SQL Loader)

    Hello Gurus,
    I have some data in .dat file which needs to be loaded into oracle table. I am using SQL * Loader to do the job. Although "NULLIF col_name =BLANKS" works for character datatype, but when value for date col is NULL then I get ORA-01841 error. I have to make NULL for all rows withour value for date column
    Early reply will be highly appreciated
    Farooq

    Hi,
    May be this problem is not with the NULLIF. The value for the date column is not in proper date format.
    create table:
    create table kk (empno number, ename varchar2(20), deptno number, hiredate date)
    Control file:
    LOAD DATA
    INFILE 'd:\kk\empdata.dat'
    insert into TABLE kk ( empno position (1:2) integer external,
    ename position(4:5) char NULLIF ename=BLANKS,
    deptno position (7:8) integer external NULLIF deptno=BLANKS,
    hiredate position (10:20) date NULLIF hiredate=BLANKS)
    data file:
    10 KK 01-jan-2005
    20 10
    SELECT * FROM KK;
    EMPNO ENAME DEPTNO HIREDATE
    10 KK 01-JAN-05
    20 10
    Verify the data file.
    Hope it will help

  • SDIMA: Values for field SUPP_EXIST in condition table CNCCRMPRCUS801 differ

    Hi Experts,
    when checking condition records consistency between CRM and ERP via transacation SDIMA we get the following error for one of the conditon records: 'Values for field SUPP_EXIST in condition table CNCCRMPRCUS801 differ'. Can anybody explain to me where this message could come from? To my understanding field 'SUPP_EXIST' only exists in CRM condition tables for technical reason. So no way to compare this against an ERP condition table field, is there?
    And related to this: I found that this error message is triggered from method CL_CND_DIMA_CRM->COMPARE_MBDOC. As the DIMA-Compare is triggered asynchronously and just setting a break-point is no option therefore, I was wondering if anybody knows a way of debugging this method in order to find out what the coding does in detail before the message is thrown.
    Thanks a lot for your help!
    Cheers,
    Jens

    Hi Brian and the other Experts,
    thanks for your help. Unfortunately, I don't have a single record with this problem but a lot more. So it is not possible to correct this manually. Also, I would not know how to correct this anyhow as I don't understand what field in R/3 should map to field SUPP_EXIST in CRM condition tables. Let me explain:
    From my understanding, in CRM (leave aside scales) we have two database tables for each condition table, a central and a supplemental table. A condition record always creates a data record in the central table and nothing is inserted in the supplemental table in case that the fields form the supplemental table are not needed. However, when there are less common condition features involved (e.g. uppler limits), then an additional data record will be created in the supplemental table with the relevant data. And this is when field SUPP_EXIST comes into play as it is an indicator for the system that a data record exists for that condition record also in the supplemental table.
    The condition record data model in R/3 is completely different. For CRM condition table CNCCRMPRCUS801 the following tables in R/3 are involved: A801, KONH and KONP. And there is a data record for each of them for a given condition record. There is no concept of having a supplemental table as far as I understand it so where exactly would I find this SUPP_EXIST in R/3 so that I can make sure it does not deviate from the data in CRM?
    Would be great if someone could give me another hint. What am I getting wrong?
    Cheers,
    Jens

  • Need (procedure or function or sql query )for Email filter

    Hi All,
    in (procedure or function or sql query ) ,if i pass the a input parameter like (anbu@y or anbu@ or anbu@yahjjj ) ,i need to get output like [email protected] .
    please give me code for this ...

    SQL> with t
      2  as
      3  (
      4  select 'anbu@y' email from dual union all
      5  select 'anbu@' from dual union all
      6  select 'anbu@yahjjj' from dual
      7  )
      8  select email, regexp_replace(email, '@.*','@yahoo.com') email_new
      9    from t
    10  /
    EMAIL
    EMAIL_NEW
    anbu@y
    [email protected]
    anbu@
    [email protected]
    anbu@yahjjj
    [email protected]

  • F4 help values for currency key field in table

    Hi all,
    I have added currency and currency key fields in my Z table. For the curreny key field, i have assigned the standard data element WAERS. I have implemented Table Maintenance Generator for my table. But the F4 help values for the currency key field is not appearing when i tried to maintain table entry.
    Should i need to check the Foreign key check box for the field attribute? But this check box is in disable field in screen layout.
    Could someone tell me how to solve this issue?

    Hi,
    Make the check table of the currency field of your Ztable as TCURC,which is the master table of Currency.Inside the domain of the field you write the TCURC as a value table.and make foriegn key relationship with the TCURC table.
    Regards,
    Suvajit.

  • How to pick max value from a column of a table using cursor and iteration

    Hello Everybody
    I have a table loan_detail
    and a column in it loan_amount
    now i want to pick values from this table using cursor and then by using iteration i want to pick max value from it using that cursor
    here is my table
    LOAN_AMOUNT
    100
    200
    300
    400
    500
    5600
    700i was able to do it using simple loop concepts but when i was trying to do this by using cursor i was not able to do it .
    Regards
    Peeyush

    SQL> SELECT MAX(sal) Highest_Sal,MIN(sal) Lowest_Sal FROM emp;
    HIGHEST_SAL LOWEST_SAL
           5000        800
    SQL> set serverout on
    SQL> DECLARE
      2    TYPE tmp_tbl IS TABLE OF NUMBER INDEX BY BINARY_INTEGER;
      3    sal_tbl tmp_tbl;
      4    CURSOR emp_sal IS
      5      SELECT sal FROM emp;
      6    counter INTEGER := 1;
      7  BEGIN
      8    FOR i IN emp_sal LOOP
      9      sal_tbl(i.sal) := counter;
    10      counter := counter + 1;
    11    END LOOP;
    12    DBMS_OUTPUT.put_line('Lowest SAL:' || sal_tbl.FIRST);
    13    DBMS_OUTPUT.put_line('Highest SAL:' || sal_tbl.LAST);
    14  END;
    15  /
    Lowest SAL:800
    Highest SAL:5000
    PL/SQL procedure successfully completed.
    SQL> Even smaller
    SQL> DECLARE
      2    TYPE tmp_tbl IS TABLE OF NUMBER INDEX BY BINARY_INTEGER;
      3    sal_tbl tmp_tbl;
      4    CURSOR emp_sal IS
      5      SELECT sal FROM emp;
      6    counter INTEGER := 1;
      7  BEGIN
      8    FOR i IN emp_sal LOOP
      9      sal_tbl(i.sal) := 1;
    10    END LOOP;
    11    DBMS_OUTPUT.put_line('Lowest SAL:' || sal_tbl.FIRST);
    12    DBMS_OUTPUT.put_line('Highest SAL:' || sal_tbl.LAST);
    13  END;
    14  /
    Lowest SAL:800
    Highest SAL:5000
    PL/SQL procedure successfully completed.
    SQL> Edited by: Saubhik on Jan 5, 2011 4:41 PM

  • Default value for a reference cursor argument to a package function

    I'm trying to do the following to allow the caller to pass in a ref cursor arg or a SrcTextID (internal). Anyway, I'm just trying to use defaults, rather than overloading the routine, but I can't figure out how to default a ref cursor variable.
    FUNCTION f_execute_query_and_build_file(
         bn_debug_mode_in                              IN           common_func.BOOLEAN_NUMBER,
         n_ahs_file_definition_id_in          IN           AHS_FILE_DEFINITION.AHS_FILE_DEFINITION_ID%TYPE,
         lst_ordered_column_names               IN           common_func.STRING_TABLE,
         s_file_directory_in                         IN           VARCHAR2 := null,
         s_file_name_in                                   IN           VARCHAR2 := null,
         n_src_text_query_id_in                    IN           SRC_TEXT.SRC_TEXT_ID%TYPE := Null,
         refcur_query_in                              IN           sys_refcursor := Null,
         s_error_msg_out                                   OUT      common_func.T_ERROR_MSG )
    RETURN NUMBERThis causes a "PLS-00382 expression is of wrong type" msg. Okay, so fine. Then I thought that I would declare a package level "empty" ref cursor to act as "empty" default...which causes a "PLS-00994 Cursor Variables cannot be declared as part of a package" msg.
    Any ideas?
    Thanks,
    Jason

    in 10g you can...Unfortunately 9i doesn't like it:
    scott@ORA92> DECLARE
      2    variable_name SYS_REFCURSOR := NULL;
      3  BEGIN
      4    NULL;
      5  END;
      6  /
      variable_name SYS_REFCURSOR := NULL;
    ERROR at line 2:
    ORA-06550: line 2, column 34:
    PLS-00382: expression is of wrong type
    ORA-06550: line 2, column 17:
    PL/SQL: Item ignored
    scott@ORA92> DECLARE
      2    PROCEDURE procedure_name (
      3        parameter_name IN SYS_REFCURSOR := NULL)
      4    IS
      5    BEGIN
      6        NULL;
      7    END;
      8  BEGIN
      9    procedure_name;
    10  END;
    11  /
        parameter_name IN SYS_REFCURSOR := NULL)
    ERROR at line 3:
    ORA-06550: line 3, column 40:
    PLS-00382: expression is of wrong type
    ORA-06550: line 2, column 3:
    PL/SQL: Item ignored
    ORA-06550: line 9, column 3:
    PLS-00306: wrong number or types of arguments in call to 'PROCEDURE_NAME'
    ORA-06550: line 9, column 3:
    PL/SQL: Statement ignored
    Barbara what is the difference between 'DEFAULT' and
    ':=' in parameter declarations?Apparently there is no difference. My mistake. I have always used default. Somewhere along the way I obtained the misimpression that using := would overwrite a passed value, similar to the way it would when used between is/as and begin, whereas default would only use the default value if another value was not passed. I don't recall where I got that idea. The test below shows that my presumption was wrong:
    scott@ORA92> CREATE OR REPLACE PROCEDURE test
      2    (p_1 IN VARCHAR2 DEFAULT 'default value for p_1',
      3       p_2 IN VARCHAR2 := 'defualt value for p_2')
      4  AS
      5  BEGIN
      6    DBMS_OUTPUT.PUT_LINE (p_1);
      7    DBMS_OUTPUT.PUT_LINE (p_2);
      8  END test;
      9  /
    Procedure created.
    scott@ORA92> SHOW ERRORS
    No errors.
    scott@ORA92> SET SERVEROUTPUT ON
    scott@ORA92> EXECUTE test ('passed value for p_1', 'passed value for p_2')
    passed value for p_1
    passed value for p_2
    PL/SQL procedure successfully completed.
    scott@ORA92>

  • Based on input file i need to update default values to some columns of database table using bulk copy process

    Hi Team,
    Am using BULK INSERT Format file option to load data into table from .txt file here am facing an issue i.e ibased on input file i need to insert default values to some columns of table so we can not declare it on table level, Can we give default values in
    format file ? if we can give how it is ? or Any alternate possibilities to this scenario instead of BULK INSERT ?
    Thanks,
    Sudhakar

    Thanks for your response, here i don't have any rights to change table structure the table is created by different team, my work is to load data from file to table. Is there any chance to supply default values by*XML* format file instead of *.fmt* file
    please let me know the possibility.
    Again, no. If you want to supply default values that are not present in DEFAULT constraints in the table definition, you will need to write your own code. There are plentyfull of options, and I have mentioned some already.
    Here are some more:
    *  Table-valued parameters, see here for examples:
    http://www.sommarskog.se/arrays-in-sql-2008.html
    *  Use BULK INSERT to load data to a staging table, and then apply the default values when you copy from staging to target.
    Erland Sommarskog, SQL Server MVP, [email protected]

  • How to map single input value to Two columns of Database table using format file of Bulk Copy Process

    Hi All,
    Am using OPENROWSET to load the file data into table, here the problem is i need to map same input value to two different columns of table, As format file doesn't allow the duplicate numbers am unable to insert same value to two columns, please help me to
    find a solution for this. 
    i can use only OPENROWSET because i need to insert some default values also which come based on file. only the problem is how to map same input value to two different columns of table. please give me the suggestions.
    Thanks,
    Sudhakar

    From what you say:
       INSERT tbl(col1, col2)
          SELECT col1, col1
          FROM   OPENROWSET(....)
    But I guess it is more difficult. You need to give more details. What sort of data source do you have? What does your query look like? The target table?
    Erland Sommarskog, SQL Server MVP, [email protected]
    Hi Erland,
    Thanks for your response
    my source file is text file with | symbol separate for ex:
    1002|eTab |V101|eTablet|V100|Logic|LT-7|Laptops|SCM
    Database table have columns like
    column1,column2,column3...etc, now i need to insert same value from input file into two columns for ex:
    the eTab value from text file has to be insert into column2 and column3 of
    table
    we cannot change format file like below one
    for the above situation how can we insert eTab into column2 and column3
    Thanks,
    Sudhakar.

  • How to call webservice for each record in a table using ODI

    Hi
    I am new to ODI and Webservice. I want to invoke a scenario in ODI using web service. I hava a weblogic application server with axis 2 deployed.
    But I want call webservice for each record in a table
    For eg: "EMP" table have 50 records, for each record web service should invoke
    Can any one help me on it.
    Thanks,
    phani
    Edited by: user12774166 on Jun 6, 2010 11:16 PM

    If your goal is "call" a web service, Jason's Straub's [flex-ws-api|https://flex-ws-api.samplecode.oracle.com/] is by far the best I've seen. You might want read more about it on [his blog|http://jastraub.blogspot.com/search?q=+flex_ws_api+].
    Tyler Muth
    http://tylermuth.wordpress.com
    [Applied Oracle Security: Developing Secure Database and Middleware Environments|http://sn.im/aos.book]

  • Unalbe to delete lock entry table using Dequeue function module

    Friends,
    I display a base ALV list with custom app. tool bar. When i click on a button, i submit another report which updates a z-table for that corresponding row. I create a lock object for this entry before submitting the report. After updating the table, I try to delete the lock object using dequeue function module in the called report, but though the subrc is 0, the lock entry is not getting deleted in SM12. The called report, after dequeue, again submits report 1 (the caller). So, when i try to do some operation for the same row which I first selected, it triggers Foreign_lock exception. When I completely go out of the base list, only then the entry is deleted. Can anyone tell me the reason? I have tried with parameters _SCOPE & _SYNCHRON, but same result.
    Regards,
    Sathish R

    Hi,
    The triggering of the dequeue is not in the proper position as it need to be placed.
    Thats the only problem as per u have described the issue.
    Place the deque as soon as the report is return the value.
    I hope it may work ur issue.

  • Update sap table using a function module call by php code

    Hello,
    I m trying to update the table VBAP using a function module ZZ_SET_DISTANCE  call by a php code.
    But I have this problem:
    the saprfc seems to work well but when I look to the table VBAP the fields have not been update.
    I tried the function module in debug mode and it work good. The fields are update.
    I also handle the saprfc call function and the return SAPRFC_OK
    This are the function module ZZ_SET_DISTANCE, and the php code
    //PHP CODE
    $fce = saprfc_function_discover($sap,"ZZ_SET_DISTANCE");
                  if (! $fce ) {echo "Echec d'ouverture du module fonction "; exit;}
                   saprfc_import ($fce,"COMMANDE", '0000001998');
                   saprfc_table_init($fce,"TBLE_CMDE");
                        $val=array();
                        $val['NUM_POST']='000030';
                        $val['HN_EXP']='';
                        $val['ST_EXP']='';
                        $val['PC_EXP']='';
                        $val['CI_EXP']='';
                        $val['CO_EXP']='';
                        $val['HN_REC']='';
                        $val['ST_REC']='';
                        $val['PC_REC']='';
                        $val['CI_REC']='';
                        $val['CO_REC']='';
                        $val['DIST']='popo';
                        saprfc_table_append ($fce,"TBLE_CMDE", $val);
                 $rfc_rc = saprfc_call_and_receive ($fce);
                 echo "\n".$rfc_rc;
                 if ($rfc_rc != SAPRFC_OK) { if ($sap == SAPRFC_EXCEPTION ) echo ("Exception raised: ".saprfc_exception($fce)); else echo (saprfc_error($fce)); }else{echo '/execution de la function ;}
                 saprfc_function_free($fce);
    //FUNCTION MODULE ZZ_SET_DISTANCE
    FUNCTION ZZ_SET_DISTANCE.
    ""Local Interface:
    *"  IMPORTING
    *"     VALUE(COMMANDE) TYPE  VBELN
    *"  TABLES
    *"      TBLE_CMDE STRUCTURE  ZADD_COM_LOXAN
    DATA : NUMC TYPE VBELN.
    NUMC = COMMANDE .
    WHILE STRLEN( NUMC ) < 10 .
      CONCATENATE '0' NUMC INTO NUMC .
    ENDWHILE .
    DATA tble_addrcomm LIKE LINE OF TBLE_CMDE .
    LOOP AT  TBLE_CMDE INTO  tble_addrcomm.
      DATA : NUMP TYPE POSNR.
      NUMP = tble_addrcomm-NUM_POST.
      WHILE STRLEN( NUMP ) < 6 .
      CONCATENATE '0' NUMP INTO NUMP .
      ENDWHILE .
      UPDATE VBAP SET ARKTX = tble_addrcomm-DIST
      WHERE VBELN EQ COMMANDE
      AND POSNR EQ NUMP.
    ENDLOOP.
    ENDFUNCTION.
    Is anybody can help me?
    thank.

    Marie, create a Blog please, about more details for dummies....
    1) how to connect to sap system?
    2) you run the php code where? in a webserver or where?
    3) wich is the url for run the FM: ZZ_SET_DISTANCE
    4) you placed some dlls files on the web server?
    please is interesting this...
    Thanks

  • Displaying table using call function 'REUSE_ALV_GRID_DISPLAY'

    I have created a table which has product code, product description, and product level.  I am trying to display it using REUSE_ALV_GRID_DISPLAY.  When I Check it, I get the following error message: "PVS2" is not an internal table - the "Occurs n" specification is missing.
    Is it possible to copy PVS2 into another table, and then display that table using REUSE_ALV_GRID_DISPLAY?
    I have patched together code from sdn, a client program, and my own code and I am starting to get confused.  So, please help me.
    Regards,
    Al Lal
    REPORT  YABHINAV16.
    * program to display products at chosen level *
    Tables: T179, T179t.
    types:  begin of hierarchy,
            prodh type t179-prodh,
            vtext type t179t-vtext,
            stufe type t179-stufe,
            end of hierarchy.
    types: begin of text,
    prodh type t179t-prodh,
    vtext type t179t-vtext,
    end of text.
    data: pvs type standard table of hierarchy initial size 0.
    data: pvs2 type hierarchy.
    data: it_text type standard table of text,
    wa_text type text.
    TYPE-POOLS:SLIS.
    *For ALV
    DATA: GT_FLD TYPE SLIS_T_FIELDCAT_ALV,
          GT_EV TYPE SLIS_T_EVENT,
          GT_HDR TYPE SLIS_T_LISTHEADER,
          GT_SORT TYPE SLIS_T_SORTINFO_ALV.
    DATA: WA_FLD TYPE SLIS_FIELDCAT_ALV,
          WA_EV TYPE SLIS_ALV_EVENT,
          WA_HDR TYPE SLIS_LISTHEADER,
          WA_SORT TYPE SLIS_SORTINFO_ALV,
          WA_LAYOUT TYPE SLIS_LAYOUT_ALV.
    DEFINE FLD.
      WA_FLD-FIELDNAME   = &1.
      WA_FLD-TABNAME     = &2.
      WA_FLD-OUTPUTLEN   = &3.
      WA_FLD-SELTEXT_L   = &4.
      WA_FLD-SELTEXT_M   = &5.
      WA_FLD-SELTEXT_S   = &6.
      WA_FLD-COL_POS     = &7.
      WA_FLD-FIX_COLUMN  = &8.
      WA_FLD-DO_SUM      = &9.
      APPEND WA_FLD TO GT_FLD.
      CLEAR WA_FLD.
    END-OF-DEFINITION.
    CONSTANTS: C_TOP TYPE SLIS_FORMNAME VALUE 'TOP_OF_PAGE',
               C_USER_COMMAND            TYPE  SLIS_FORMNAME  VALUE 'USER_COMMAND'.
    DATA: MTRL LIKE SY-REPID,
          TITLE LIKE SY-TITLE.
    select-options level for t179-stufe no intervals.
    start-of-selection.
    Select prodh stufe from T179 into corresponding fields of table pvs where stufe in level.
    select prodh vtext from t179t into corresponding fields of table it_text for all entries in pvs where prodh = pvs-prodh.
    end-of-selection.
    sort pvs by prodh.
    sort it_text by prodh.
    loop at pvs into pvs2.
      read table it_text into wa_text with key prodh = pvs2-prodh.
      if sy-subrc eq 0.
        pvs2-vtext = wa_text-vtext.
        write: / pvs2-prodh, pvs2-vtext, pvs2-stufe.
      endif.
    *  modify pvs2.
    endloop.
    perform BUILD_FIELDCAT.
    perform GRID_DISPLAY.
    form BUILD_FIELDCAT .
        FLD 'PRODH'   'PVS2'   '20'     'Product Hierarchy'        ' ' ' '  '1'  ''   '' .
        FLD 'VTEXT'   'PVS2'   '40'     'Description '        ' ' ' '  '3'  ''   '' .
        FLD 'STUFE'   'PVS2'    '5'    'Level'        ' ' ' '  '2'  ''   '' .
    endform.                    " BUILD_FIELDCAT
    form GRID_DISPLAY .
      call function 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          I_CALLBACK_PROGRAM      = MTRL
          I_CALLBACK_USER_COMMAND = 'C_USER_COMMAND'
          I_CALLBACK_TOP_OF_PAGE  = C_TOP
          I_STRUCTURE_NAME        = 'PVS2'
          IS_LAYOUT               = WA_LAYOUT
          IT_FIELDCAT             = GT_FLD
          IT_SORT                 = GT_SORT
          I_DEFAULT               = 'X'
          I_SAVE                  = 'U'
          IT_EVENTS               = GT_EV
        TABLES
          T_OUTTAB                = PVS2[]
        EXCEPTIONS
          PROGRAM_ERROR           = 1
          others                  = 2.
      if SY-SUBRC <> 0.
        message id SY-MSGID type SY-MSGTY number SY-MSGNO
                with SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      endif.
    endform.                    " GRID_DISPLAY

    TYPE-POOLS : SLIS.
    DATA : BEGIN OF WA_T001,
                 BUKRS LIKE T001-BUKRS,
                 BUTXT LIKE T001-BUTXT,
                 ORT01 LIKE T001-ORT01,
                 END OF WA_T001,
                 IT_T001 LIKE TABLE OF WA_T001.
    DATA : IT_FCAT TYPE SLIS_T_FIELDCAT_ALV,
                WA_FCAT LIKE LINE OF IT_FCAT.
    DATA : V_NAME LIKE  SY-REPID.
    SELECT BUKRS BUTXT ORT01 FROM T001 INTO TABLE IT_T001 UP TO 15 ROWS. V_NAME = SY-REPID.
    CALL FUCTION MODULE 'REUSE_ALV_FIELDCATLOG_MERGE. EXPORTING  I_CALBACK_PROGRAM =
    V_NAME I_INTERAL_TABNAME = 'WA_T001' I_INCLNAME = V_NAME CHANGING CT_FIELDCAT =
    IT_FCAT.
    CALL FUNCTION MODULE "REUSE_ALV_GRID_DISPLAY"
    EXPORTING
    I_CALLBACK_PROGRAM = V_NAME
    IT_FCAT = IT_FCAT.
    TABLES
         T_OUTTAB  = IT_T001
    SY-REPID IS THE SYSTEM VARIABLE WHICH IS HAVING THE ABAP PROGRAM 
    OR CURRENT MAIN PROGRAM.
    ----- Sample Progam -
    ***INCLUDE YRVR058_DEST_WISE_SUMMARY_DF01 .
    *&      Form  DISPLAY_DATA
          text      *-- Rajesh Vasudeva
    -->  p1        text
    <--  p2        text
    FORM DISPLAY_DATA .
      IF ITAB[] IS NOT  INITIAL.
        PERFORM F_APPEND_BLOCK.
      ELSE.
        MESSAGE 'Data not found for the selection
    criteria' TYPE 'S'.
        LEAVE LIST-PROCESSING.
      ENDIF.
    ENDFORM.                    " display_data
    *&      Form  f_append_block
          text
    -->  p1        text
    <--  p2        text
    FORM F_APPEND_BLOCK .
      DATA : L_WA_SORT    TYPE SLIS_SORTINFO_ALV,   "For
    sort
             L_WA_EVENTS  TYPE SLIS_ALV_EVENT.      "For
    events
    Event (Top of List)
      CLEAR L_WA_EVENTS.
      L_WA_EVENTS-NAME = SLIS_EV_TOP_OF_LIST.
      L_WA_EVENTS-FORM = C_TOPOFPAGE.
      APPEND L_WA_EVENTS TO I_EVENTS_PART.
    Event (Top of Page)
      CLEAR L_WA_EVENTS.
      L_WA_EVENTS-NAME = SLIS_EV_TOP_OF_PAGE.
      L_WA_EVENTS-FORM = 'F_DISPLAY_HEADER_PARTA'(031).
      "f_display_header_part
      APPEND L_WA_EVENTS TO I_EVENTS_PART.
    Event (End of List)
      CLEAR L_WA_EVENTS.
      L_WA_EVENTS-NAME = SLIS_EV_END_OF_LIST.
      L_WA_EVENTS-FORM = C_END_OF_LIST.
      APPEND L_WA_EVENTS TO I_EVENTS_PART.
    Set Layout Zebra
      STRUCT_LAYOUT-ZEBRA          = 'X'.
      STRUCT_LAYOUT-NUMC_SUM       = 'X'.
      STRUCT_LAYOUT-TOTALS_TEXT    = 'TOTAL:'(032).
    set field catalog
      PERFORM F_FIELD_CATALOG_PART.
      ASSIGN ITAB[] TO <F_OUTTAB>.
      V_PART = 'A'.  "initiating list is A
      PERFORM F_DISPLAY_BLOCK USING STRUCT_LAYOUT
                                   I_FIELD_CAT_PART[]
                                   C_TAB
                                   I_EVENTS_PART[]
                                   I_SORT_PART[].
    ENDFORM.                    " f_append_block
    *&      Form  f_field_catalog_part
          text
    -->  p1        text
    <--  p2        text
    FORM F_FIELD_CATALOG_PART .
      REFRESH I_FIELD_CAT_PART.
      CLEAR I_FIELD_CAT_PART.
      PERFORM F_CREATE_CATALOG USING :
    *Month
    C_TAB 'MONTH'  'MONTH'      SPACE 'L' 7
    I_FIELD_CAT_PART[],
    *OBD
    *C_TAB 'VBELN'  'Delivery'      SPACE 'L' 12
    I_FIELD_CAT_PART[],
    *DATE
    C_TAB 'WADAT_IST'  'Date'      SPACE 'L' 10
    I_FIELD_CAT_PART[],
    *Destination
    C_TAB 'CITY1'  'Destination'      SPACE 'L' 25
    I_FIELD_CAT_PART[],
    *Qty By Road
    C_TAB 'NTGEW_ROAD'  'Road Quantity'   SPACE 'R' 16
    I_FIELD_CAT_PART[],
    *Rail Qty
    C_TAB 'NTGEW_RAIL'  'Rail Quantity'  SPACE 'R' 16 I_FIELD_CAT_PART[],
    *Total  Qty C_TAB 'TOT'  'Total Quantity'  SPACE 'R' 16 I_FIELD_CAT_PART[], *RR/Trk No.
      C_TAB 'EXTI2'  'Truck/RR No.' SPACE 'L' 17 I_FIELD_CAT_PART[].
    ENDFORM.                    " f_field_catalog_part
    *&      Form  f_DISPLAY_block
          text
         -->P_STRUCT_LAYOUT  text
         -->P_I_FIELD_CAT_PART[]  text
         -->P_C_TAB  text
         -->P_I_EVENTS_PART[]  text
         -->P_I_SORT_PART[]  text
    FORM F_DISPLAY_BLOCK  USING  FP_LAYOUT         TYPE
    SLIS_LAYOUT_ALV
                                 FP_I_FCAT         TYPE
    SLIS_T_FIELDCAT_ALV
                                 VALUE(FP_TABNAME) TYPE
    ANY
                                 FP_I_EVENTS       TYPE
    SLIS_T_EVENT
                                 FP_I_SORT         TYPE
    SLIS_T_SORTINFO_ALV.
      DATA: V_REPID  TYPE SYREPID,                 
    "current Program id
            C_SAVE       TYPE CHAR1 VALUE 'A'.     
    "variant save
      V_REPID = SY-REPID.
      CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
    *CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          I_CALLBACK_PROGRAM = V_REPID
          IS_LAYOUT          = FP_LAYOUT
          IT_FIELDCAT        = FP_I_FCAT[]
          IT_SORT            = FP_I_SORT[]
          I_SAVE             = C_SAVE             "variant
    save
          IT_EVENTS          = FP_I_EVENTS[]
        TABLES
          T_OUTTAB           = <F_OUTTAB>
        EXCEPTIONS
          PROGRAM_ERROR      = 1
          OTHERS             = 2.
      IF SY-SUBRC <> 0.
        MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDFORM.                    " f_DISPLAY_block
    *&      Form  f_create_catalog
          text
         -->P_C_TAB  text
         -->P_0085   text
         -->P_0086   text
         -->P_SPACE  text
         -->P_0088   text
         -->P_5      text
         -->P_I_FIELD_CAT_PART[]  text
    FORM F_CREATE_CATALOG  USING  FP_I_TABNAME   TYPE
    SLIS_TABNAME
                                  FP_I_FIELDNAME TYPE SLIS_FIELDNAME
                                  FP_I_SELTEXT   TYPE
    SCRTEXT_L
                                  FP_I_DOSUM     TYPE
    CHAR1
                                  FP_I_JUST      TYPE C
                                  FP_I_OUTPUTLEN TYPE
    OUTPUTLEN
                                  FP_I_FCAT      TYPE
    SLIS_T_FIELDCAT_ALV.
    Record for field catalog
      DATA: L_REC_FCAT TYPE SLIS_FIELDCAT_ALV.
      L_REC_FCAT-TABNAME   = FP_I_TABNAME.
      L_REC_FCAT-FIELDNAME = FP_I_FIELDNAME.
      L_REC_FCAT-SELTEXT_L = FP_I_SELTEXT.
      L_REC_FCAT-DO_SUM    = 'X'.
    *l_rec_fcat-do_sum    = ' '.
      L_REC_FCAT-JUST      = FP_I_JUST.
      L_REC_FCAT-OUTPUTLEN = FP_I_OUTPUTLEN.
      L_REC_FCAT-DECIMALS_OUT = '2'.
      L_REC_FCAT-KEY          = '1'.
      APPEND L_REC_FCAT TO FP_I_FCAT.
    ENDFORM.                    " f_create_catalog
         Subroutines for Headings
    *&      Form  f_display_header_partA
          Display header for report for Part A
    *&      Form  top_of_page
          text
    -->  p1        text
    <--  p2        text
    FORM TOP_OF_PAGE .
      SKIP 1.
      WRITE:/25 ' Name of Company ',80 'RUN DATE' ,
    SY-DATUM.
    SKIP 1.
    WRITE:/60 'RUN DATE' , SY-DATUM.
      SKIP 1.
      DATA: YR(4) TYPE N,
             FIN_PRD(10) TYPE C.
      IF S_DTABF-LOW+4(2) LT '04'.
        YR = S_DTABF-LOW+0(4) - 1.
        CONCATENATE YR '-' S_DTABF-LOW+2(2) INTO FIN_PRD.
      ELSE.
        YR = S_DTABF-LOW+0(4) + 1.
        CONCATENATE S_DTABF-LOW0(4) '-' YR2(2) INTO
    FIN_PRD.
      ENDIF.
      WRITE:/5 'DETAILS OF THE MONTH/DATE WISE DESPATCHES
    MADE BY ROAD/RAIL DURING THE YEAR ' , FIN_PRD  .
      SKIP 1.
    WRITE :/ 'SALES OFFICE : ' , P_SALES,' ' , RNAME.
    SKIP 1.
    ENDFORM.                    " DISPLAY_DATA
    Award Points If Useful...

Maybe you are looking for

  • HT204387 I told my iPod to forget a Bluetooth device, how do I get it to recognize that device now?

    I told my iPod to forget a Bluetooth device, how do I get it to recognize that device now?

  • Brightness on monitor resets

    I have a 17" Imac. The new ones with the intel core 2 duo. The base model. The monitor is set automatically to full brightness and it is too bright for me so I lowerd it in the system preferences. When I restart the computer the brightness goes all t

  • Broadband Speed Drop to 0.1MB

    Hello everybody, I'm having problems with my broadband, and would appreciate if anybody has had similar issues and can offer advice. I usually receive speeds of 2.5MB.  For nine days I have had a constant speed of 0.1MB.  I contacted BT on July 22nd

  • 10.6.7

    Can anybody please help... I upgraded to 10.6.7 on my iMac and now iTune, iLife and iWork apps don't launch.. yet all of adobe suit apps work w no problems. Any advise?

  • Primary Server went down going to get a fresh object elsewhere in the clust

    C:\>java -cp c:/oc4j_extended/j2ee/home/oc4j.jar;c:/how-to-ejb-clustering/lib/st ackClient.jar cluster.client.ClusterClient [One] [One, Two] [One, Two, Three] Kill current server and press Enter to continue. Primary Server went down going to get a fr