Dynamic Selections (Shift + F4) in a ALV

Hi all!
I have to simulate the work of  ME80FN transaction in a report 'Z' with simple alv.
I have to include  the dynamic selections button too (Shift + f4).
Is it possible?
Can I put this functionality in a alv?
Thanks!

Those free selections are bound to the logical database MEPOLDB.
You can program something similar yourself as explained by ABAP meister Horst Keller here:
/people/horst.keller/blog/2009/09/03/abap-geek-13--interactive-dynamic-where-clauses
Thomas

Similar Messages

  • Dynamic selections. transaction fbl3n

    hello,
    I need to create a new dynamic dynpro like in the transaction fbl3n. Particulary I have to regenerate the same event when I click the button dynamic selections (shift+f4). Someone could help me, please?
    THank you in advance.

    Here is an interesting blog by triple black belt ABAPer Horst Keller on dynamic selections, maybe you can use some of the information for your purpose.
    ABAP Geek 13 - Interactive Dynamic WHERE Clauses
    Thomas

  • Dynamic selection in ALV report

    Hi Guru's
    I have cpoied a standatrd program(RFBILA00) into Z-program.
    I need to display the profit centre from dynamic selection in ALV header  output when profit centre is selected.If not no need to display it.
    Please do the needful.
    Thanks,
    Sunil.

    hi,
    Refer to the link,
    http://www.abapcode.info/2007/06/dynamic-selection-on-alv-at-run-time.html
    This may help you.
    Regards
    Sumit Aagrwal

  • Alv Output after dynamic selection screen

    Hi Guys
    I have coded a dynamic selection screen (shown below). I want to create an ALV report based on what the user enters in the selection screen. Is the right way of doing this to code an IF s_matnr is not initial statement then call all the subroutines for output of material data and then else call a second batch of subroutines for billing data. It seems a bit long winded to me but I haven't been able to find anything on google that clearly explains the approach.
    REPORT  ZTREVOR_DYNAMIC_ALV_MAKT_VBRP.
    TABLES : makt,
    marc,
    t001w,
    vbrk,
    vbrp.
    CONSTANTS : c_yes TYPE c VALUE '1',
    c_no TYPE c VALUE '0'.
    Selection-screen begin of block b1 with frame title text-sc1.
    PARAMETERS : p_opt1 TYPE c RADIOBUTTON GROUP radi USER-COMMAND op1, "Material
    p_opt2 TYPE c RADIOBUTTON GROUP radi.                  "Billing Document
    Selection-screen end of block b1.
    Selection-screen begin of block b2 with frame title text-sc2.
    SELECT-OPTIONS : s_matnr FOR makt-matnr MODIF ID op1, "Material
    s_vbeln FOR vbrp-vbeln MODIF ID op2. "Billing Document
    Selection-screen end of block b2.
    T SELECTION-SCREEN OUTPUT.
    LOOP AT SCREEN .
    IF screen-group1 = 'OP1' .
    IF p_opt1 = 'X' .
    screen-invisible = c_no .
    screen-active = c_yes .
    ELSE.
    screen-invisible = c_yes .
    screen-active = c_no .
    ENDIF.
    MODIFY SCREEN .
    ENDIF.
    IF screen-group1 = 'OP2' .
    IF p_opt2 = 'X' .
    screen-invisible = c_no .
    screen-active = c_yes .
    ELSE.
    screen-invisible = c_yes .
    screen-active = c_no .
    ENDIF.
    MODIFY SCREEN .
    ENDIF.
    ENDLOOP.

    Hi,
    First of all, you should check your radiobutton instead of select-option...
    Then you will have to build the output internal table dynamically based on the option chosen. There are lot of example on SDN...
    Here is a start: http://wiki.sdn.sap.com/wiki/display/Snippets/Tutorialabap-CodeforDynamicAlv+grid
    Kr,
    m.

  • How to save a variant with dynamic selections parameters

    Anybody knows how to save a variant for an ABAP that uses a Logical database with Dynamic Selections?
    Have a look for example to the following:
    SE38 - DEMO_PROGRAM_GET - Execute - Shift F4 - Connection Number.
    How to save 0820 as Connection Number?
    Function Group SVAR seems good but FREE SELECTIONs are not easy to manage...

    Hello,
      I tried to save the variant of DEMO_PROGRAM_GET with dynamic selection field (Connection Number) filled. It gets saved without any problem. Just click 'SAVE' and enter the variant name and description.
    Thanks,
    Venu

  • ABAP Help: Dynamic Selection Screen

    Hi,
    I have a requirement to be able to pick the list of fields in a selection screen. (List processing)
    Similar to SE16 choosing "fields for selection".
    I've debugged SE16 and realized it deletes the report and regenerates a new report with the updated selection screen.
    I could not do the same as it will also delete all the variants users have created in the report.
    Has anyone done something similar before?
    What is the best approach for this scenario?
    Regards,
    Michael Pang

    Hi Michael
    Hoping you have solved your problems with ALVs, I think it may be helpful to inspect FMs <b>"FREE_SELECTIONS_INIT"</b> and <b>"FREE_SELECTIONS_DIALOG"</b> for this issue. They have some <i>Function Module Documentation</i>.
    If you are dealing with logical databases, then only in the INCLUDE program DB<i>ldb</i>SEL of logical database <i>ldb</i>, you can use some selection-screen definition variants as:
    1.SELECTION-SCREEN BEGIN OF VERSION vers TEXT-xxx.
    2.SELECTION-SCREEN END OF VERSION vers.
    3.SELECTION-SCREEN EXCLUDE ... .
    4.SELECTION-SCREEN DYNAMIC SELECTIONS FOR TABLE dbtab.
    5.SELECTION-SCREEN FIELD SELECTION FOR TABLE dbtab.
    6.SELECTION-SCREEN DYNAMIC SELECTIONS FOR NODE node.
    7.SELECTION-SCREEN FIELD SELECTION FOR NODE node.
    You can get more info from SAPHelp for these...
    *--Serdar

  • Dynamic select

    hi to all,
            i am working in the dynamic select scenario. i want to select the fieldnames  from the tables dynamically using report editor as per the requirement as new to abap can some one please help me out and also kindly mention the table name for example DD03L.
    Thanks,
    Devi

    Hi priya...
    I am sure about its may help you....please mention if you solve your questions..
    REPORT  ZNKS_TEST19.
    *TABLES : SFLIGHT.
    type-pools : slis.
    data : it_tab  type table of SFLIGHT,
          wa_tab  like line of it_tab.
    data: fieldcatalog type slis_t_fieldcat_alv with header line,
          gd_layout    type slis_layout_alv,
          gd_repid     like sy-repid,
          g_exit type c,
          ispfli type table of spfli.
    parameters :
                carrid  type SFLIGHT-CARRID,
                connid  type SFLIGHT-CONNID,
                date  type SFLIGHT-FLDATE,
                price  type SFLIGHT-PRICE.
    data l_where(100) occurs 0 with header line.
    start-of-selection.
      perform data_retrivel.
      perform build_fieldcatalog.
      perform display_alv_report.
    form build_fieldcatalog .
      fieldcatalog-fieldname   = 'CARRID'.
      fieldcatalog-seltext_m   = 'carrid'.
      fieldcatalog-col_pos     = 0.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'CONNID'.
      fieldcatalog-seltext_m   = 'connid'.
      fieldcatalog-col_pos     = 1.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'FLDATE'.
      fieldcatalog-seltext_m   = 'date'.
      fieldcatalog-col_pos     = 2.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
      fieldcatalog-fieldname   = 'PRICE'.
      fieldcatalog-seltext_m   = 'price'.
      fieldcatalog-col_pos     = 3.
      fieldcatalog-outputlen   = 20.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
       fieldcatalog-fieldname   = 'CURRENCY'.
      fieldcatalog-seltext_m   = 'currency'.
      fieldcatalog-col_pos     = 4.
      fieldcatalog-outputlen   = 20.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
       fieldcatalog-fieldname   = 'PLANETYPE'.
      fieldcatalog-seltext_m   = 'planetype'.
      fieldcatalog-col_pos     = 5.
      fieldcatalog-outputlen   = 20.
      append fieldcatalog to fieldcatalog.
      clear  fieldcatalog.
    endform.                    " BUILD_FIELDCATALOG
    form display_alv_report .
      gd_repid = sy-repid.
      call function 'REUSE_ALV_GRID_DISPLAY'
        exporting
          i_callback_program      = gd_repid
          i_callback_top_of_page  = 'TOP-OF-PAGE'  "see FORM
          i_callback_user_command = 'USER_COMMAND'
          it_fieldcat             = fieldcatalog[]
          i_save                  = 'X'
    *      IS_VARIANT              = G_VARIANT
        tables
          t_outtab                = it_tab
        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.                    "DISPLAY_ALV_REPORT
    form data_retrivel .
      if carrid is not initial.
    append 'CARRID = carrid' to l_where.
    endif.
    if connid  is not initial.
      if l_where is initial.
        append ' and ' to l_where.
      endif.
      append 'CONNID = connid' to l_where.
    endif.
    if date  is not initial.
      if l_where is initial.
        append ' and ' to l_where.
      endif.
      append 'FLDATE = date' to l_where.
    endif.
    if price is not initial.
      if l_where is initial.
        append ' and ' to l_where.
      endif.
      append 'PRICE = price' to l_where.
    endif.
    select * from sflight into corresponding fields of table it_tab
    where (l_where).
    endform.                    " DATA_RETRIVEL
    form top-of-page.
    *ALV Header declarations
      data: t_header type slis_t_listheader,
            wa_header type slis_listheader,
            t_line like wa_header-info,
            ld_lines type i,
            ld_linesc(10) type c.
    * Title
      wa_header-typ  = 'H'.
      wa_header-info = 'Z  report'.
      append wa_header to t_header.
      clear wa_header.
    * Date
      wa_header-typ  = 'S'.
      wa_header-key = 'Date: '.
      concatenate  sy-datum+6(2) '.'
                   sy-datum+4(2) '.'
                   sy-datum(4) into wa_header-info.   "todays date
      append wa_header to t_header.
      clear: wa_header.
      call function 'REUSE_ALV_COMMENTARY_WRITE'
        exporting
          it_list_commentary = t_header.
    endform.    
    // Dynamic Selection
    Thanks and Regards ,
    Niraj Sinha

  • Dynamic select of unknown fields

    Hello,
    I just started abap last monday and I'm still very new in it. I have a problem and i would appreciate if some one could detaily tell me how I could solve this problem. I have search in this forum but I haven't found any thing close to what I really want to do.
    Many contracts could be tied to a single projet and also many payments could be tied to a single contract.
    I am looking for a way so that I could dynamically determine the number of all contracts belonging to a particular project. There is a table called <u>prps</u> in sap. this table contains all projects data. There is also another table called <u>prhi</u> which contains all the contracts to a project. The field in prps is <u>prps-posid</u> for the the project number. The contract field in prhi is <u>prhi-posnr</u>
    I have put all the project numers in a <u>range r_projetnr</u> for <u>prhi-up</u>.
    Now my problem is how could I dynamically select all the contracts belonging to a project.
    I would appreciate any tips on how to do this.
    Thanks
    Claudi

    Thanks you all for your respond. I think I need to be more precise. I have all the project numbers packed in a range <u>r_projectnr.</u>
    With all the project numbers packed in a range I have selected all the contracts already like this:
    data: lt_prhi
    SELECT * FROM prhi INTO CORRESPONDING FIELDS OF TABLE lt_prhi
       WHERE up IN r_projectnr.
      IF sy-subrc <> 0.
        EXIT.
      ELSE.
    * out put the data dynamically to alv output.
    clear w_output.
    CLEAR w_output.
    * t_output is my output structure which already has some fields among them the projectnr.
    * I have already selected the projectnr and outputed it to
    * t_output.
        LOOP AT t_ouput INTO w_output.
          CLEAR w_prhi.
          w_tabix_1 = 0.
          SORT lt_prhi.
          LOOP AT t_prhi INTO w_prhi WHERE psphi = w_output-projectnr.
            w_tabix_1 = w_tabix_1 + 1.
            CASE w_tabix_1.
    WHEN 1.
    *   assign first contract to t_output
                w_outpu-contractnr1           = w_prhi-posnr.
    * some more constants data come here
    WHEN 2.
                w_output-contractnr2          = w_prhi-posnr.
    * some more constant data would come here.
    WHEN 3.
    WHEN 4
    ENDCASE
    This way may be good if only a certain number of contracts are expected to be outputed. But in a case like mine where I want to output all contracts belonging to a particular project, I need a dynamic way of doing this. I have a structure defined with 4 contracts but I would also need to know a way of dynamically expanding this structure depending on the number of contracts found in one project. I hope this explains my difficult situation as a freshman in abap.
    Thank you
    Claudi Tim
    Message was edited by:
            Tim claudi
    Message was edited by:
            Tim claudi
    Message was edited by:
            Tim claudi

  • Adding BKPF_XREF1_HD field for FBL3n and FBL1N dynamic selection

    Hi Friends,
    Is there any possible way to add the BKPD-XREF1_HD field to FBL1N and FBL3N transactions?
    As per my knowledge both are line item related process which contains other than BKPF table entries. Bue my client wants to add in the Dynamic selection as it available for FB03 transaction.
    I tried thru SE36 but no result. (BRF)
    Please adivse what are all the ways to do that or is there any SAP notes available for possible or not possible solution.
    Plaase reply.
    Thanks & Regards
    Sankar.

    Hello Sankar babu,
    These fields need to be setup as Special Fields in T021S. You can do this by the following path in IMG:
    Financial Accounting->General Ledger Accounting->G/L Accounts-> Line Items->Display Line Items with ALV->Define Special Fields for Finding and Sorting Data. (transaction OBVU).
    Please check SAP note 207436. It describes you how you should act to see the field XREF* in transaction FBL*N.
    Regarding the Special Fields, please see SAP Note 215798.  This note will explain that the special fields need to be in table T021S as well as in the RFPOSXEXT structure which can be verified in SE11.  If these fields are not yet in RFPOSXEXT see Note 215798 (you can verify this in RFPOSXEXT by going to the bottom of the structure and see under column 'Component' that special fields are denoted by 'U_XREF1').  You may see a field XREF1 under the 'Component' column, but these fields are NOT the special field.  The special field is denoted by U_fieldname!!!
    However, the field BKPF-XREF1_HD is used in Real Estate module. In this field, you can define control information for all line items.This field is used in third-party management in RE to assign a business transaction to a third party.
    Please note that table BKPF is not directly selected in the logical database, so the usage of the field in the selection views in SE36 will not work. So you may have to create the field in the index tables.
    I hope this information helps.
    Thank you.
    Suresh Jayanthi.

  • Urgent :  how to select the rows in the ALV Grid Control

    How to select the rows in the ALV Grid control,
    I am facing the situation where i need to select the row/rows in the Grid control and then to lock the entries,
    If anyone have the solution please help me out
    <b>Its very Urgent</b>

    Hi Bharath,
    Go through this hope u can understand.
    SEL_MODE. Selection mode, determines how rows can be selected. Can have the following values:
    A Multiple columns, multiple rows with selection buttons.
    B Simple selection, listbox, Single row/column
    C Multiple rows without buttons
    D Multiple rows with buttons and select all ICON
    Setting and getting selected rows (Columns) and read line contents
    You can read which rows of the grid that has been selected, and dynamic select rows of the grid using methods get_selected_rows and set_selected_rows. There are similar methods for columns.
    Note that the grid table always has the rows in the same sequence as displayed in the grid, thus you can use the index of the selected row(s) to read the information in the rows from the table. In the examples below the grid table is named gi_sflight.
    Data declaration:
    DATA:
    Internal table for indexes of selected rows
    gi_index_rows TYPE lvc_t_row,
    Information about 1 row
    g_selected_row LIKE lvc_s_row.
    Example 1: Reading index of selected row(s) and using it to read the grid table
      CALL METHOD go_grid->get_selected_rows
        IMPORTING
          et_index_rows = gi_index_rows.
      DESCRIBE TABLE gi_index_rows LINES l_lines.
      IF l_lines = 0.
        CALL FUNCTION 'POPUP_TO_DISPLAY_TEXT'
             EXPORTING
                  textline1 = 'You must choose a valid line'.
        EXIT.
      ENDIF.
      LOOP AT gi_index_rows INTO g_selected_row.
         READ TABLE gi_sflight INDEX g_selected_row-index INTO g_wa_sflight.
        ENDIF.
      ENDLOOP.
    Example 2: Set selected row(s).
      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.
      ENDIF.
    Reward points if helpful.
    Thanks
    Naveen khan

  • Dynamic plan shift..

    Hi everbody..
    We have three daily work schedule.  The set of daily work schedules is defined on basis of the period work schedule using the "Dynamic Daily Planned/Actual Overlap" view (V_T552W).
    And we assinged one period work schedule  to employee.
    Period work schedule'S free day on sunday.
    We use DYNWS function for Dynamic plan shift in schema.
    It works but unfortunately our shift's free day changes. For example 7:00-15:00 shift's free day sunday but 23:00-07:00 shift's free day on saturday. We want to use one period work schedule for three shift, do you have any suggestion for this problem.
    Thanks  alot.

    Do you want to build this using drag 'n drop?
    Do you have the 'handle' of the selected image? That is, do
    you <img> component that's holding your image?
    Is you destination also an <img> component?
    if so, just set the source url of dest <img> to the
    source <img>. Similarly for the drag and drop you'd change
    the source of destination image on drop event.
    If this is not what you're looking, a further elaboration
    would be helpful.
    ATTA

  • How to get resultset from procedure having dynamic select sql query ?

    Hi,
    I have created a procedure, in which there is dynamic select query. The procedure has one out put parameter which gives error code. When I compile that procedure it compiles successufully. When I run it it executes successfully and gives output error code. But I don't know how to get resultset of that dynamic select sql query. I need that.
    This is the procedure:
    create or replace
    PROCEDURE uspGetProductDetailsMultiOrder
      v_DefinitionDBName IN VARCHAR2,
         v_CommonDBName IN VARCHAR2,
         v_Filter_FilledStatus IN VARCHAR2,
         v_Filter_Internal_Counterparty IN nvarchar2,
         v_Filter_NoteType IN nvarchar2,
         v_Filter_Exchange IN nvarchar2,
         v_Filter_Issuer IN nvarchar2,
         v_Filter_Product_Category  IN VARCHAR2,
         v_DateToFilter IN VARCHAR2,     
         v_Filter_FromDate IN VARCHAR2,
         v_Filter_ToDate IN VARCHAR2,
         v_Active_YN_Flag IN NVARCHAR2,
         v_Entity_ID IN NVARCHAR2,
         v_ErrorNumber  OUT NUMBER
       as
       v_SelectSQL  nvarchar2(32767);
          v_Setting_Name  nvarchar2(32767);
       v_Default_Value  nvarchar2(32767);
       v_Config_Value  nvarchar2(32767);
       v_CCY_ID  NUMBER(10,0);
       v_CCY_Data  nvarchar2(32767);
       v_CCY_List  nvarchar2(32767);
       v_Seq_Id  NUMBER(10,0);
       SWV_Active_YN_Flag NVARCHAR2(1);
       SWV_VarStr long;--varchar2(4000);
       SWV_TRANCOUNT NUMBER(10,0);
        SWV_fnc_SplitString_Id_var1 NUMBER(10,0);
       SWV_fnc_SplitString_Id_var0 NUMBER(10,0);
      CURSOR RestrictTermsheetVisibilityByC 
       IS select CS.Setting_Name,Default_Value,Config_Value
       from Config_Settings CS   LEFT OUTER JOIN Entity_Config EC  ON EC.Setting_ID = CS.Setting_ID
       where EC.Entity_ID = v_Entity_ID AND Setting_Level = 'ENTITY';
       CURSOR Get_RestrictCCY_List_Cursor IS SELECT Id_1,Data_1 FROM table(fnc_SplitString(v_Config_Value,','));
       --CURSOR Get_RestrictCCY_List_Cursor IS SELECT Id,Data FROM imp;
       CURSOR GetRestrictTemplateListCursor 
      -- is select id,data from imp;
       IS SELECT Id_1,Data_1 FROM table(fnc_SplitString(v_Config_Value,',')) ;
         --Parikshit 18-Jul-2010, active YN flag param added in SP
    BEGIN
    SWV_Active_YN_Flag := v_Active_YN_Flag;
       if SWV_Active_YN_Flag = ' '  then
          SWV_Active_YN_Flag := 'Y';
       end if;
       v_SelectSQL := ' ';
       v_SelectSQL := v_SelectSQL || ' Select ';
       v_SelectSQL := v_SelectSQL || '  NM.Note_Master_Id, NM.Product_Name, NM.Template_ID, NM.Template_Sr_No, NM.Asset, NM.Exchange, NM.Type, NM.Currency';
         --SET @SelectSQL = @SelectSQL + ' , NM.Trade_Date, NM.Value_Date, NM.Valuation_Date, NM.Maturity_Date, NM.Tenor, NM.Strike_Price_Percentage, (case when (NM.Type like '' ELN%'' or NM.Type like ''RELN%'') THEN  NOP.Issue_Price Else NM.Customer_Price End) as Customer_Price, NM.Dealer_Price, (case when (NM.Type like '' ELN%'' or NM.Type like ''RELN%'') THEN  NOP.Customer_Yield Else NM.Customer_Yield End) as Customer_Yield,  NOP.Dealer_Cost_PA as Internal_Cost '
       v_SelectSQL := v_SelectSQL || ' , NM.Trade_Date, NM.Value_Date, NM.Valuation_Date, NM.Maturity_Date, NM.Tenor, NM.Strike_Price_Percentage, (case when (NM.PriceList_YN = ''Y'') THEN  NOP.Issue_Price Else NM.Customer_Price End) as Customer_Price, NM.Dealer_Price, (case when (NM.PriceList_YN = ''Y'') THEN  NOP.Customer_Yield Else NM.Customer_Yield End) as Customer_Yield,  NOP.Dealer_Cost_PA as Internal_Cost ';
       v_SelectSQL := v_SelectSQL || ' , NM.Minimum_Issue_Size, NM.Maximum_Issue_Size, NM.Minimum_Tolerence_Amount, NM.Maximum_Tolerence_Amount, NM.Trigger_Amount_Warning, nvl(NM.PerUnit_Equivalent_Amount,1) as PerUnit_Equivalent_Amount,  NM.Active_YN_Flag, NM.Verify_YN_Flag ';
       v_SelectSQL := v_SelectSQL || ' , NM.Tranche_YN_Flag, NM.Launch_Date, NM.Open_Date, NM.Close_Date, NM.PreHedged_YN, NM.Created_By, NM.Created_At,  NM.Verified_At, NM.Verified_By, NM.ISIN, NM.Issuer';
       v_SelectSQL := v_SelectSQL || ' , NM.Product_Catagory as Product_Category, NM.Note_Issuer_Type as Issuer_Category, NM.Series_No as Series_No, NM.Minimum_Investment_Amount ';
         --Added by Parikshit on 14-Jun-2011, to remove the unwinding amounts from the total issue size
         --SET @SelectSQL = @SelectSQL + ' , NOP.LastTimeWhenProductModified,NOP.Nominal_Amount as Current_Issue_Size, NOP.Filled_Status, NM.Counterparty as Internal_Counterparty  '
       v_SelectSQL := v_SelectSQL || ' , NOP.LastTimeWhenProductModified,(NOP.Nominal_Amount - nvl(ND.Unwind_Amount,0) ) as Current_Issue_Size, NOP.Filled_Status, NM.Counterparty as Internal_Counterparty  ';
         --********************************************************END
       v_SelectSQL := v_SelectSQL || ' ,T2.Confirmed_Amount, T2.Confirmed_Shares';
       v_SelectSQL := v_SelectSQL || ' , T3.Live_Deals';
       v_SelectSQL := v_SelectSQL || ' , BS.Net_Trade_Hedged, BS.Net_Trade_Outstanding, BS.Hedged_Nominal_BUY, BS.Hedged_Nominal_SELL, BS.Outstanding_Nominal_BUY, BS.Outstanding_Nominal_SELL   ';
       v_SelectSQL := v_SelectSQL || ' , ( case    When UPPER(NM.PreHedged_YN) = ''Y'' Then ''Launched'' ';
       v_SelectSQL := v_SelectSQL || '              When ((NM.Maturity_Date IS  NOT NULL) AND to_date(NM.Maturity_Date) <= to_date(sysdate)) Then ''Matured''';
       v_SelectSQL := v_SelectSQL || '              When (UPPER(NM.PreHedged_YN) = ''N'' AND NM.Launch_Date IS NOT NULL)  Then ''Launched''';     
         --Ready to launch
       v_SelectSQL := v_SelectSQL || '              When (UPPER(NM.PreHedged_YN) = ''N'' AND NM.Launch_Date  IS  NULL AND (T2.Confirmed_Amount >= NM.Minimum_Issue_Size) AND  to_date(Close_Date) > to_date(sysdate) ) Then ''Ready To Launch''';     
         --Ready to launch
       v_SelectSQL := v_SelectSQL || '              When (UPPER(NM.PreHedged_YN) = ''N'' AND NM.Launch_Date  IS  NULL AND (T2.Confirmed_Amount >= (NM.Minimum_Issue_Size - NM.Minimum_Tolerence_Amount)) AND  to_date(Close_Date)= to_date(sysdate)    )  Then ''Ready To Launch''';     
       v_SelectSQL := v_SelectSQL || '              When (UPPER(NM.PreHedged_YN) = ''N'' AND NM.Launch_Date  IS  NULL AND (T2.Confirmed_Amount >= (NM.Minimum_Issue_Size - NM.Minimum_Tolerence_Amount)) AND  to_date(Close_Date)< to_date(sysdate)    )  Then ''Ready To Launch''';     
         --Warning trigger reached
       v_SelectSQL := v_SelectSQL || '              When (UPPER(NM.PreHedged_YN) = ''N'' AND NM.Launch_Date IS  NOT NULL AND (T2.Confirmed_Amount >= NM.Trigger_Amount_Warning ))  Then ''Warning Trigger Reached''';          
       v_SelectSQL := v_SelectSQL || '              Else ''Not Ready'' ';
       v_SelectSQL := v_SelectSQL || '              End)Launch_Status';
       v_SelectSQL := v_SelectSQL || ' , NI.Issuer_Code';
          v_SelectSQL := v_SelectSQL || ' , (nvl(NOP.Nominal_Amount,0) - nvl(T2.Confirmed_Amount,0)) as Unconfirmed_Amount, NM.Upfront as Upfront,   case when UPPER(NM.PreHedged_YN) = ''Y'' THEN 0 else (nvl(T2.Confirmed_Amount,0) - nvl(BS.Net_Trade_Hedged,0)) end as ReadyToHedge';
          v_SelectSQL := v_SelectSQL || ' , NOP.Hard_Margin  as Margin_Amount, NM.YearBasis as YearBasis, NM.Note_Product_Rating as Equity_Risk_Score, AD.Equity_Asset_Class ';
          v_SelectSQL := v_SelectSQL || '  , NM.Note_Product_Rating as Product_Rating,  NOP.PO_ID, AD.LotSize as Lot_Size, NM.Max_Orders_Per_Product as MAX_Orders, NOP.Order_Count as Current_Order_Count,  nvl(NM.Denomination_Ccy,NM.Currency) as Denomination_Ccy, NM.Note_Scheme_Type as Underlying_Type, NM.Note_Asset_Class as Asset_Class, NULL as Product_Created_YN, NULL as Product_Created_ID,  ( (case when NM.Note_Order_Type = '''' then N''Market'' else NM.Note_Order_Type end )  ) as  Order_Type, NOP.Spot_Price, NM.Note_Price_Link, NOP.Strike_Price, NVL(NM.C_Fixing_Frequency,''Atmaturity'') as Fixing_Frequency, NM.Document_Uploaded_YN, NM.Document_Uploaded_At, NM.Document_Uploaded_By, NM.Document_File_Name, NM.Document_File_Extension, NM.Document_File_Path, NM.CutOff_Time, NM.Soft_Tenor, NM.NM_Sn_Code_All, NULL as Note_Price_Source, AD.LongName, NVL(NM.Pricelist_YN,''N'') as Pricelist_YN, AD.AlternateIdentifierAlias as Underlying, NM.Note_Issuer_Date_Offset, NM.Counterparty as Note_Counter_Party, NULL as
    Note_Premium_PC  ';
       v_SelectSQL := v_SelectSQL || '  , NI.Issuer_Name, IP.Issuer_Id, IP.Broad_Cash, IP.Odd_Cash, IP.Account_Note, IP.Rounding, IP.Decimal_Truncate, IP.Misc1 as Recidual_YN, NM.Note_Issuer_Type, NM.Target_Coupon, C_Fixing_Frequency as C_Fixing_Frequency, NM.Callable_Frequency as Callable_Frequency, NM.Strike_Price_Percentage as C_Note_Strike_PC, NM.NM_Airbag_PC as  Airbag_PC, C_Note_Barrier_PC as C_Note_Barrier_PC, TM.Template_Name, ''Product'' as Record_Type, NM.C_Settlement_Frequency, NM.Coupon_Frequency, NM.NM_Fixing_Source as Note_Fixing_Source, NM.Order_Entry_Type, (nvl(NM.Minimum_Issue_Size,0) - nvl(T2.Confirmed_Amount,0)) as Remaining_Launch_Amount, NM.C_Fixing_Start_Point, NM.C_Fixing_End_Point, NM.Order_Entry_Type, SC.Scheme_Alias, SC.Scheme_Name, CM.CM_ID, CM.CM_Name as Counterparty_Name, NM.NM_Other_Features as Other_Features, NM.Strike_Price_Percentage as Accrual_Strike, NM.NM_KnockIn as KnockIn, NM.NM_Airbag_Type, NM.NM_Put_strike as Put_Strike, NM.NM_Accrual_Strike,
    NM.NM_Counterparty_Upfront,  NM.Price_Updated_YN as Prices_Updated_YN, AD.Code as Asset_Name,NULL as KO_FREQ_TYPE, NM.Daily_Accumalation_Equities, NM.MaxNoAcc_days, NM.Guaranteed_Days, NM.Leverage_ratio, NM.NORM_IF, NM.NORM_PAIR, NM.NORM_FXRate ';
       v_SelectSQL := v_SelectSQL || ' from ';
       v_SelectSQL := v_SelectSQL || v_CommonDBName|| '.Note_Master NM  ';
       v_SelectSQL := v_SelectSQL || 'Left Outer Join ';
       v_SelectSQL := v_SelectSQL || v_CommonDBName||'.Issuer_Master NI ';
          v_SelectSQL := v_SelectSQL || ' On NM.Issuer = (case when  ISNUMERIC(NM.Issuer) = 0  then  cast (NI.Issuer_Name as nvarchar2(25))  else  cast(NI.Issuer_Id as nvarchar2(25)) end )';     
       v_SelectSQL := v_SelectSQL || ' Left Outer Join ';
       v_SelectSQL := v_SelectSQL || v_CommonDBName||'.Note_Order_Product NOP ';
       v_SelectSQL := v_SelectSQL || ' On NOP.Note_Master_ID = NM.Note_Master_ID';
       v_SelectSQL := v_SelectSQL || ' Left Outer Join ';
       v_SelectSQL := v_SelectSQL || v_DefinitionDBName||'.AssetDef AD ';
       v_SelectSQL := v_SelectSQL || ' On AD.Code = NM.Asset';
         v_SelectSQL := v_SelectSQL || ' AND AD.TypeAsset  = substr(NM.Note_Asset_Class,1,2) ';
       v_SelectSQL := v_SelectSQL || ' Left Outer Join ';
       v_SelectSQL := v_SelectSQL || v_CommonDBName||'.Issuer_Parameter IP ';
          v_SelectSQL := v_SelectSQL || ' On NM.Issuer = (case when  ISNUMERIC(NM.Issuer) = 0  then  cast (IP.Issuer_Name as nvarchar2(25))  else  cast(IP.Issuer_Id as nvarchar2(25)) end )';
       v_SelectSQL := v_SelectSQL || ' Left Outer Join ';
       v_SelectSQL := v_SelectSQL || v_CommonDBName||'.Template_Master TM ';
       v_SelectSQL := v_SelectSQL || ' On  TM.Template_Id =  NM.Template_ID ';
       v_SelectSQL := v_SelectSQL || ' Left Outer Join ';
       v_SelectSQL := v_SelectSQL || v_CommonDBName||'.Scheme_Codes SC ';
       v_SelectSQL := v_SelectSQL || ' On  SC.Scheme_Alias =  NM.Type';     
       v_SelectSQL := v_SelectSQL || ' Left Outer Join ';
       v_SelectSQL := v_SelectSQL || v_CommonDBName||'.Counterparty_Master CM ';
       v_SelectSQL := v_SelectSQL || ' On  CM.CM_ID =  NM.Counterparty';     
          v_SelectSQL := v_SelectSQL || ' Left Outer Join      ';
       v_SelectSQL := v_SelectSQL || ' ( ';
       v_SelectSQL := v_SelectSQL || ' Select Note_master_ID, sum(Nominal_Amt) as Unwind_Amount from ';
       v_SelectSQL := v_SelectSQL || v_CommonDBName||'.Note_Deals ';
       v_SelectSQL := v_SelectSQL || ' where Prematurity_Date IS NOT NULL';
       v_SelectSQL := v_SelectSQL || ' AND (UPPER(Deletion_Reason ) = ''PART REDEMPTION'' or UPPER(Deletion_Reason ) = ''FULL REDEMPTION'')';
       v_SelectSQL := v_SelectSQL || ' Group by Note_master_ID ';
       v_SelectSQL := v_SelectSQL || ' ) ND ';
       v_SelectSQL := v_SelectSQL || ' On  ND.Note_Master_ID =  NM.Note_Master_ID';
    if  (v_Filter_FilledStatus = ' ' OR UPPER(v_Filter_FilledStatus) = 'ALL' ) then
          v_SelectSQL := v_SelectSQL || ' ';
       else
          v_SelectSQL := v_SelectSQL || ' AND NOP.Filled_Status IN (' || v_Filter_FilledStatus  || ')';
       end if;                         
         --AND NOP.Internal_Counterparty = 'DEFAULT''
       if(SUBSTR(to_char(v_Filter_Internal_Counterparty),1,4000)= ' ')  then
          v_SelectSQL := v_SelectSQL || ' ';
       else
          v_SelectSQL := v_SelectSQL || ' AND NOP.Internal_Counterparty IN (' || v_Filter_Internal_Counterparty || ')';
       end if;                    
         --SET @SelectSQL = @SelectSQL + ' --Filter--'
       v_SelectSQL := v_SelectSQL || ' LEFT OUTER JOIN ';
       v_SelectSQL := v_SelectSQL || ' (';
       v_SelectSQL := v_SelectSQL || '   select Note_Master_ID, sum(Nominal_Amount) As Confirmed_Amount, sum(No_Of_Shares)  As Confirmed_Shares  ';
       v_SelectSQL := v_SelectSQL || '   from '||v_CommonDBName||'.Note_Order_RM  ';
       v_SelectSQL := v_SelectSQL || '   Where substr(UPPER(Order_Status_Flag),1,6) = ''YYYYYY'' AND substr(substr(UPPER(Order_Status_Flag),1,7),-1,1) = ''N'' ';
       v_SelectSQL := v_SelectSQL || '   group by  Note_Master_ID';
       v_SelectSQL := v_SelectSQL || ' ) T2';
       v_SelectSQL := v_SelectSQL || ' ON T2.Note_Master_ID = NM.Note_Master_ID';
       v_SelectSQL := v_SelectSQL || ' LEFT OUTER JOIN';
       v_SelectSQL := v_SelectSQL || ' (';
       v_SelectSQL := v_SelectSQL || '   Select ND.Note_Master_ID, sum(ND.Nominal_Amt) As Live_Deals ';
       v_SelectSQL := v_SelectSQL || '   from '||v_CommonDBName||'.Note_Deals ND  ';
       v_SelectSQL := v_SelectSQL || '   where ND.Active_YNFlag = ''Y'' ';
       v_SelectSQL := v_SelectSQL || '   group by  Note_Master_ID';
       v_SelectSQL := v_SelectSQL || ' ) T3';
       v_SelectSQL := v_SelectSQL || ' ON T3.Note_Master_ID = NM.Note_Master_ID';
       v_SelectSQL := v_SelectSQL || '  LEFT OUTER JOIN';
       v_SelectSQL := v_SelectSQL || '  (';
       v_SelectSQL := v_SelectSQL || '  SELECT NH_Note_Master_ID,';
       v_SelectSQL := v_SelectSQL || '  (CAST(SUM(Hedged_Nominal_Buy) AS BINARY_FLOAT) -CAST(SUM(Hedged_Nominal_Sell) AS BINARY_FLOAT))  Net_Trade_Hedged,';
       v_SelectSQL := v_SelectSQL || '  (CAST(SUM(Outstanding_Nominal_BUY) AS BINARY_FLOAT) -CAST(SUM(Outstanding_Nominal_SELL) AS BINARY_FLOAT))  Net_Trade_Outstanding,';
       v_SelectSQL := v_SelectSQL || '  SUM(Hedged_Nominal_BUY) AS Hedged_Nominal_BUY,';
       v_SelectSQL := v_SelectSQL || '  SUM(Hedged_Nominal_SELL) AS Hedged_Nominal_SELL,';
       v_SelectSQL := v_SelectSQL || '  SUM(Outstanding_Nominal_BUY) AS Outstanding_Nominal_BUY,';
       v_SelectSQL := v_SelectSQL || '  SUM(Outstanding_Nominal_SELL) As Outstanding_Nominal_SELL';
       v_SelectSQL := v_SelectSQL || '  From';
       v_SelectSQL := v_SelectSQL || '  (';
       v_SelectSQL := v_SelectSQL || '  SELECT NH_Note_Master_ID,';
       v_SelectSQL := v_SelectSQL || '  SUM(NH_Hedged_Nominal) AS Hedged_Nominal_BUY, 0 AS Hedged_Nominal_SELL,';
       v_SelectSQL := v_SelectSQL || '  SUM(NH_Outstanding_Nominal) AS Outstanding_Nominal_BUY, 0 AS Outstanding_Nominal_SELL';
       v_SelectSQL := v_SelectSQL || '  FROM '||v_CommonDBName||'.Note_Hedge  ';
       v_SelectSQL := v_SelectSQL || '  WHERE NH_Direction = ''BUY'' ';
       v_SelectSQL := v_SelectSQL || '  GROUP BY NH_Note_Master_ID';
       v_SelectSQL := v_SelectSQL || '  Union';
       v_SelectSQL := v_SelectSQL || '  SELECT NH_Note_Master_ID,';
       v_SelectSQL := v_SelectSQL || '  0 AS Hedged_Nominal_BUY, SUM(NH_Hedged_Nominal) AS Hedged_Nominal_SELL,';
       v_SelectSQL := v_SelectSQL || '  0 AS Outstanding_Nominal_BUY, SUM(NH_Outstanding_Nominal) AS Outstanding_Nominal_SELL';
       v_SelectSQL := v_SelectSQL || '  FROM '||v_CommonDBName||'.Note_Hedge  ';
       v_SelectSQL := v_SelectSQL || '  WHERE NH_Direction = ''SELL''  ';
       v_SelectSQL := v_SelectSQL || '  GROUP BY NH_Note_Master_ID';
       v_SelectSQL := v_SelectSQL || '  ) ';
       v_SelectSQL := v_SelectSQL || '  GROUP BY NH_Note_Master_ID';
       v_SelectSQL := v_SelectSQL || '  ) BS';
       v_SelectSQL := v_SelectSQL || '  ON BS.NH_Note_Master_ID = NM.Note_Master_ID';
       v_SelectSQL := v_SelectSQL || ' Where NM.Verify_YN_Flag = ''Y'' ';
      v_SelectSQL := v_SelectSQL || ' AND NM.Active_YN_Flag = ''' || SWV_Active_YN_Flag || '''';
       if(SUBSTR(to_char(v_Filter_NoteType),1,4000) = ' ' OR UPPER(v_Filter_NoteType) = 'ALL' ) then
               v_SelectSQL := v_SelectSQL || ' ';
       else
          v_SelectSQL := v_SelectSQL || ' AND NM.Type IN (' || v_Filter_NoteType  || ')';
       end if;     
    IF UPPER(v_Entity_ID) <> 'ALL'  then
          OPEN RestrictTermsheetVisibilityByC;
          FETCH RestrictTermsheetVisibilityByC INTO v_Setting_Name,v_Default_Value,v_Config_Value;
          WHILE RestrictTermsheetVisibilityByC%FOUND   LOOP
         --2) Convert comma separated ccy (CNY,HKD,USD) string to single quote ccy with comma separated Ccy ('CNY','HKD','USD') string
             if (UPPER(v_Setting_Name) = 'RESTRICT_TERMSHEET_VISIBILITY_BY_CCY')  then
                if v_Config_Value is not null  then
              SELECT COUNT(Id_1) INTO SWV_fnc_SplitString_Id_var0 FROM TABLE(fnc_SplitString(v_Config_Value,',')) ;
                   IF (SWV_fnc_SplitString_Id_var0 > 0)  then
                        --print 'Before Single  quote separated ccy : ' + '''' + @Config_Value + ''''
                      v_Seq_Id := 0;
                      OPEN Get_RestrictCCY_List_Cursor;
                      FETCH Get_RestrictCCY_List_Cursor
                      INTO v_CCY_ID,v_CCY_Data;
                      WHILE Get_RestrictCCY_List_Cursor%FOUND   LOOP
                         if v_Seq_Id = 0  then
                            v_CCY_List := '''' || v_CCY_Data || '''';
                         else
                            v_CCY_List := v_CCY_List || ',' || '''' || v_CCY_Data || '''';
                         end if;
                         v_Seq_Id := v_Seq_Id+1;
                         FETCH Get_RestrictCCY_List_Cursor INTO v_CCY_ID,v_CCY_Data;
                      END LOOP;
                      CLOSE Get_RestrictCCY_List_Cursor;
                        --print 'After Single quote ccy : ' + @CCY_List
                      v_SelectSQL := v_SelectSQL || ' AND nvl(NM.Denomination_Ccy,NM.Currency) NOT IN (' || v_CCY_List   || ')';
                   end if;
                end if;
             end if;
    --3) Convert comma separated template (ELN,BELN,BELN_B) string to single quote template code with comma separated template ('ELN','BELN','BELN_B') string
             if (UPPER(v_Setting_Name) = 'RESTRICT_TERMSHEET_VISIBILITY_BY_SUBSCHEME')  then
                if v_Config_Value is not null then
          SELECT COUNT(Id_1) INTO SWV_fnc_SplitString_Id_var1 FROM TABLE(fnc_SplitString(v_Config_Value,',')) ;
                   IF (SWV_fnc_SplitString_Id_var1 > 0)  then
                      v_Seq_Id := 0;
                      OPEN GetRestrictTemplateListCursor;
                      FETCH GetRestrictTemplateListCursor
                      INTO v_CCY_ID,v_CCY_Data;
                      WHILE GetRestrictTemplateListCursor%FOUND 
                      LOOP
                         if v_Seq_Id = 0  then
                            v_CCY_List := '''' || v_CCY_Data || '''';
                         else
                            v_CCY_List := v_CCY_List || ',' || '''' || v_CCY_Data || '''';
                         end if;
                         v_Seq_Id := v_Seq_Id+1;
                         FETCH GetRestrictTemplateListCursor INTO v_CCY_ID,v_CCY_Data;
                      END LOOP;
                      CLOSE GetRestrictTemplateListCursor;
                   --print 'After Single quote template code: ' + @CCY_List
                      v_SelectSQL := v_SelectSQL || ' AND TM.Template_Code NOT IN (' || v_CCY_List   || ')';
                   end if;
                end if;
             end if;
             FETCH RestrictTermsheetVisibilityByC INTO v_Setting_Name,v_Default_Value,v_Config_Value;
          END LOOP;
          CLOSE RestrictTermsheetVisibilityByC;
       end if;
      if  (v_Filter_Exchange = ' ' OR UPPER(v_Filter_Exchange) = 'ALL')  then
          v_SelectSQL := v_SelectSQL || ' ';
       else
          v_SelectSQL := v_SelectSQL || ' AND NM.Exchange IN (' || v_Filter_Exchange  || ')';
       end if;                         
         --SET @SelectSQL = @SelectSQL + ' --AND NM.Issuer = 4'
      if  (v_Filter_Issuer = ' ' OR UPPER(v_Filter_Issuer) = 'ALL') then
          v_SelectSQL := v_SelectSQL || ' ';
       else
          v_SelectSQL := v_SelectSQL || ' AND NM.Issuer IN (' || v_Filter_Issuer  || ')';
       end if;     
          if  v_Filter_Product_Category    = ' '  then
          v_SelectSQL := v_SelectSQL || ' ';
       else
          v_SelectSQL := v_SelectSQL || ' AND UPPER(NM.Note_Issuer_Type) IN (''' || v_Filter_Product_Category  || ''')';
       end if;          
       if UPPER(v_DateToFilter) = 'NA'  then
          v_SelectSQL := v_SelectSQL || ' ';
       else
          if UPPER(v_DateToFilter) = 'CLOSE_DATE'  then
             v_SelectSQL := v_SelectSQL || ' AND to_char( '|| v_DateToFilter || ') >= to_date(''' || v_Filter_ToDate ||  ''');
                             -- AND convert(smalldatetime,''' || v_Filter_ToDate || ''',106) ';
          else
             v_SelectSQL := v_SelectSQL || ' AND to_char(''' || v_DateToFilter || ''') BETWEEN to_date(''' || v_Filter_FromDate ||  ''') AND to_date(''' || v_Filter_ToDate || ''') ';
          end if;
       end if;
       v_SelectSQL := v_SelectSQL || ' Order by NM.Product_Name';
       SWV_VarStr := v_SelectSQL;
       DBMS_OUTPUT.PUT_LINE(SWV_VarStr);
       EXECUTE IMMEDIATE SWV_VarStr;
       IF SQLCODE <> 0  then
          GOTO ERROR_HANDLER;
       end if;
       IF SQL%rowcount > 0  then
          COMMIT;
          SWV_TRANCOUNT := SWV_TRANCOUNT -1;
       end if;     --Commit Transaction
       v_ErrorNumber := SQLCODE;
       RETURN;
       << ERROR_HANDLER >> v_ErrorNumber := SQLCODE;
       ROLLBACK;
       SWV_TRANCOUNT := 0;     --Rollback Transaction
       RETURN;
    END;Please suggest something. Thanks
    Edited by: BluShadow on 30-Nov-2011 11:00
    added {noformat}{noformat} tags for formatting of code.  Please read {message:id=9360002} to learn to do this yourself in future.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    Connecting to the database sample_adf_finiq_common.
    Select NM.Note_Master_Id, NM.Product_Name, NM.Template_ID, NM.Template_Sr_No, NM.Asset, NM.Exchange, NM.Type, NM.Currency , NM.Trade_Date, NM.Value_Date, NM.Valuation_Date, NM.Maturity_Date, NM.Tenor, NM.Strike_Price_Percentage, (case when (NM.PriceList_YN = 'Y') THEN NOP.Issue_Price Else NM.Customer_Price End) as Customer_Price, NM.Dealer_Price, (case when (NM.PriceList_YN = 'Y') THEN NOP.Customer_Yield Else NM.Customer_Yield End) as Customer_Yield, NOP.Dealer_Cost_PA as Internal_Cost , NM.Minimum_Issue_Size, NM.Maximum_Issue_Size, NM.Minimum_Tolerence_Amount, NM.Maximum_Tolerence_Amount, NM.Trigger_Amount_Warning, nvl(NM.PerUnit_Equivalent_Amount,1) as PerUnit_Equivalent_Amount, NM.Active_YN_Flag, NM.Verify_YN_Flag , NM.Tranche_YN_Flag, NM.Launch_Date, NM.Open_Date, NM.Close_Date, NM.PreHedged_YN, NM.Created_By, NM.Created_At, NM.Verified_At, NM.Verified_By, NM.ISIN, NM.Issuer , NM.Product_Catagory as Product_Category, NM.Note_Issuer_Type as Issuer_Category, NM.Series_No as Series_No, NM.Minimum_Investment_Amount , NOP.LastTimeWhenProductModified,(NOP.Nominal_Amount - nvl(ND.Unwind_Amount,0) ) as Current_Issue_Size, NOP.Filled_Status, NM.Counterparty as Internal_Counterparty ,T2.Confirmed_Amount, T2.Confirmed_Shares , T3.Live_Deals , BS.Net_Trade_Hedged, BS.Net_Trade_Outstanding, BS.Hedged_Nominal_BUY, BS.Hedged_Nominal_SELL, BS.Outstanding_Nominal_BUY, BS.Outstanding_Nominal_SELL , ( case When UPPER(NM.PreHedged_YN) = 'Y' Then 'Launched' When ((NM.Maturity_Date IS NOT NULL) AND to_date(NM.Maturity_Date) <= to_date(sysdate)) Then 'Matured' When (UPPER(NM.PreHedged_YN) = 'N' AND NM.Launch_Date IS NOT NULL) Then 'Launched' When (UPPER(NM.PreHedged_YN) = 'N' AND NM.Launch_Date IS NULL AND (T2.Confirmed_Amount >= NM.Minimum_Issue_Size) AND to_date(Close_Date) > to_date(sysdate) ) Then 'Ready To Launch' When (UPPER(NM.PreHedged_YN) = 'N' AND NM.Launch_Date IS NULL AND (T2.Confirmed_Amount >= (NM.Minimum_Issue_Size - NM.Minimum_Tolerence_Amount)) AND to_date(Close_Date)= to_date(sysdate) ) Then 'Ready To Launch' When (UPPER(NM.PreHedged_YN) = 'N' AND NM.Launch_Date IS NULL AND (T2.Confirmed_Amount >= (NM.Minimum_Issue_Size - NM.Minimum_Tolerence_Amount)) AND to_date(Close_Date)< to_date(sysdate) ) Then 'Ready To Launch' When (UPPER(NM.PreHedged_YN) = 'N' AND NM.Launch_Date IS NOT NULL AND (T2.Confirmed_Amount >= NM.Trigger_Amount_Warning )) Then 'Warning Trigger Reached' Else 'Not Ready' End)Launch_Status , NI.Issuer_Code , (nvl(NOP.Nominal_Amount,0) - nvl(T2.Confirmed_Amount,0)) as Unconfirmed_Amount, NM.Upfront as Upfront, case when UPPER(NM.PreHedged_YN) = 'Y' THEN 0 else (nvl(T2.Confirmed_Amount,0) - nvl(BS.Net_Trade_Hedged,0)) end as ReadyToHedge , NOP.Hard_Margin as Margin_Amount, NM.YearBasis as YearBasis, NM.Note_Product_Rating as Equity_Risk_Score, AD.Equity_Asset_Class , NM.Note_Product_Rating as Product_Rating, NOP.PO_ID, AD.LotSize as Lot_Size, NM.Max_Orders_Per_Product as MAX_Orders, NOP.Order_Count as Current_Order_Count, nvl(NM.Denomination_Ccy,NM.Currency) as Denomination_Ccy, NM.Note_Scheme_Type as Underlying_Type, NM.Note_Asset_Class as Asset_Class, NULL as Product_Created_YN, NULL as Product_Created_ID, ( (case when NM.Note_Order_Type = '' then N'Market' else NM.Note_Order_Type end ) ) as Order_Type, NOP.Spot_Price, NM.Note_Price_Link, NOP.Strike_Price, NVL(NM.C_Fixing_Frequency,'Atmaturity') as Fixing_Frequency, NM.Document_Uploaded_YN, NM.Document_Uploaded_At, NM.Document_Uploaded_By, NM.Document_File_Name, NM.Document_File_Extension, NM.Document_File_Path, NM.CutOff_Time, NM.Soft_Tenor, NM.NM_Sn_Code_All, NULL as Note_Price_Source, AD.LongName, NVL(NM.Pricelist_YN,'N') as Pricelist_YN, AD.AlternateIdentifierAlias as Underlying, NM.Note_Issuer_Date_Offset, NM.Counterparty as Note_Counter_Party, NULL as
    Note_Premium_PC , NI.Issuer_Name, IP.Issuer_Id, IP.Broad_Cash, IP.Odd_Cash, IP.Account_Note, IP.Rounding, IP.Decimal_Truncate, IP.Misc1 as Recidual_YN, NM.Note_Issuer_Type, NM.Target_Coupon, C_Fixing_Frequency as C_Fixing_Frequency, NM.Callable_Frequency as Callable_Frequency, NM.Strike_Price_Percentage as C_Note_Strike_PC, NM.NM_Airbag_PC as Airbag_PC, C_Note_Barrier_PC as C_Note_Barrier_PC, TM.Template_Name, 'Product' as Record_Type, NM.C_Settlement_Frequency, NM.Coupon_Frequency, NM.NM_Fixing_Source as Note_Fixing_Source, NM.Order_Entry_Type, (nvl(NM.Minimum_Issue_Size,0) - nvl(T2.Confirmed_Amount,0)) as Remaining_Launch_Amount, NM.C_Fixing_Start_Point, NM.C_Fixing_End_Point, NM.Order_Entry_Type, SC.Scheme_Alias, SC.Scheme_Name, CM.CM_ID, CM.CM_Name as Counterparty_Name, NM.NM_Other_Features as Other_Features, NM.Strike_Price_Percentage as Accrual_Strike, NM.NM_KnockIn as KnockIn, NM.NM_Airbag_Type, NM.NM_Put_strike as Put_Strike, NM.NM_Accrual_Strike,
    NM.NM_Counterparty_Upfront, NM.Price_Updated_YN as Prices_Updated_YN, AD.Code as Asset_Name,NULL as KO_FREQ_TYPE, NM.Daily_Accumalation_Equities, NM.MaxNoAcc_days, NM.Guaranteed_Days, NM.Leverage_ratio, NM.NORM_IF, NM.NORM_PAIR, NM.NORM_FXRate from Sample_ADF_finiq_Common.Note_Master NM Left Outer Join Sample_ADF_finiq_Common.Issuer_Master NI On NM.Issuer = (case when ISNUMERIC(NM.Issuer) = 0 then cast (NI.Issuer_Name as nvarchar2(25)) else cast(NI.Issuer_Id as nvarchar2(25)) end ) Left Outer Join Sample_ADF_finiq_Common.Note_Order_Product NOP On NOP.Note_Master_ID = NM.Note_Master_ID Left Outer Join Sample_ADF_finiq_Common.AssetDef AD On AD.Code = NM.Asset AND AD.TypeAsset = substr(NM.Note_Asset_Class,1,2) Left Outer Join Sample_ADF_finiq_Common.Issuer_Parameter IP On NM.Issuer = (case when ISNUMERIC(NM.Issuer) = 0 then cast (IP.Issuer_Name as nvarchar2(25)) else cast(IP.Issuer_Id as nvarchar2(25)) end ) Left Outer Join Sample_ADF_finiq_Common.Template_Master TM On TM.Template_Id = NM.Template_ID Left Outer Join Sample_ADF_finiq_Common.Scheme_Codes SC On SC.Scheme_Alias = NM.Type Left Outer Join Sample_ADF_finiq_Common.Counterparty_Master CM On CM.CM_ID = NM.Counterparty Left Outer Join      ( Select Note_master_ID, sum(Nominal_Amt) as Unwind_Amount from Sample_ADF_finiq_Common.Note_Deals where Prematurity_Date IS NOT NULL AND (UPPER(Deletion_Reason ) = 'PART REDEMPTION' or UPPER(Deletion_Reason ) = 'FULL REDEMPTION') Group by Note_master_ID ) ND On ND.Note_Master_ID = NM.Note_Master_ID AND NOP.Internal_Counterparty IN (1) LEFT OUTER JOIN ( select Note_Master_ID, sum(Nominal_Amount) As Confirmed_Amount, sum(No_Of_Shares) As Confirmed_Shares from Sample_ADF_finiq_Common.Note_Order_RM Where substr(UPPER(Order_Status_Flag),1,6) = 'YYYYYY' AND substr(substr(UPPER(Order_Status_Flag),1,7),-1,1) = 'N' group by Note_Master_ID ) T2 ON T2.Note_Master_ID = NM.Note_Master_ID LEFT OUTER JOIN ( Select ND.Note_Master_ID, sum(ND.Nominal_Amt) As Live_Deals from Sample_ADF_finiq_Common.Note_Deals ND where ND.Active_YNFlag = 'Y' group by Note_Master_ID ) T3 ON T3.Note_Master_ID = NM.Note_Master_ID LEFT OUTER JOIN ( SELECT NH_Note_Master_ID, (CAST(SUM(Hedged_Nominal_Buy) AS BINARY_FLOAT) -CAST(SUM(Hedged_Nominal_Sell) AS BINARY_FLOAT)) Net_Trade_Hedged, (CAST(SUM(Outstanding_Nominal_BUY) AS BINARY_FLOAT) -CAST(SUM(Outstanding_Nominal_SELL) AS BINARY_FLOAT)) Net_Trade_Outstanding, SUM(Hedged_Nominal_BUY) AS Hedged_Nominal_BUY, SUM(Hedged_Nominal_SELL) AS Hedged_Nominal_SELL, SUM(Outstanding_Nominal_BUY) AS Outstanding_Nominal_BUY, SUM(Outstanding_Nominal_SELL) As Outstanding_Nominal_SELL From ( SELECT NH_Note_Master_ID, SUM(NH_Hedged_Nominal) AS Hedged_Nominal_BUY, 0 AS Hedged_Nominal_SELL, SUM(NH_Outstanding_Nominal) AS Outstanding_Nominal_BUY, 0 AS Outstanding_Nominal_SELL FROM Sample_ADF_finiq_Common.Note_Hedge WHERE NH_Direction = 'BUY' GROUP BY NH_Note_Master_ID Union SELECT NH_Note_Master_ID, 0 AS Hedged_Nominal_BUY, SUM(NH_Hedged_Nominal) AS Hedged_Nominal_SELL, 0 AS Outstanding_Nominal_BUY, SUM(NH_Outstanding_Nominal) AS Outstanding_Nominal_SELL FROM Sample_ADF_finiq_Common.Note_Hedge WHERE NH_Direction = 'SELL' GROUP BY NH_Note_Master_ID ) GROUP BY NH_Note_Master_ID ) BS ON BS.NH_Note_Master_ID = NM.Note_Master_ID Where NM.Verify_YN_Flag = 'Y' AND NM.Active_YN_Flag = 'Y' AND UPPER(NM.Note_Issuer_Type) IN ('Internal') AND to_char('16-oct-11') BETWEEN to_date('15-oct-11') AND to_date('17-oct-11') Order by NM.Product_Name
    V_ERRORNUMBER = 0
    Process exited.
    Disconnecting from the database sample_adf_finiq_common.
    here v_errornumber=0 is the output when i run it in oracle sql developer.

  • Problem in dynamic selection in vendor balance report  tcode S_ALR_87012082

    Hello Friends,
    After upgrading from 4.7 to ecc 6.0 we are facing the below mentioned problem.
    In a Vendor Balances report, the document selection is not available in the dynamic selections and hence i am not able to select the business area to suit the requirement. We have only, vendor master and company code in the dynamic selections.
    Is there any customization tht needs to be set???
    Thanks,
    Sunny

    Hi Vas,
    I am not sure..... but you can view the details in "S_ALR_87012079", you need to chnage the layout....
    If the hint is useful… Say thanks by reward….
    Regards,
    Prabhu Rajesh

  • FBL5N Dynamic Selection

    Hi,
    When they use FBL5N to minimize the selection of data to the Branch level they need to open the Dynamic Selections area of the selection screen, scroll down (page down several times) in the left panel in a long list of available fields to find "Branch account", double click on the field to activate it in the right panel.  Once activated the Branch number can be entered in the screen to see only the documents related to the Branch.
    It would be quicker and more efficient if the Branch account field was defaulted to active in the Dynamic Selections area in FBL5N.  The default setting will save the scrolling and clicking part of getting the Branch data and make the system easier to use.
    The change will create a transportable Workbench request.
    Can anyone please explain how to bring this Branch account field in Dynamic selection as has been mentioned above.
    I will be grateful
    Warm Regards

    Hi,
    Please refer the below link for the process to add/remove any fields in the dynamic selection. If you want any field to selected by default on the right side of the screen then, in T.Code: SE36 for the Logical Database (refer the below link) you need to preselect the desired field.
    http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/b0e0039a-0d79-2c10-0aaf-9f6c062c0ffb?quicklink=index&overridelayout=true
    Regards,
    Kiron Kumar T.

  • How to add a field in dynamic selections

    HI,
    There is a requirement in which i need to add a field in existing program of dynamic selections.
    I have added a field in the screen.But I was not able to write the label and is not displaying.
    I ahve copied evrything from existing coding.but still.
    In the program ,Field groups are being used.
    I have inserted my field in that header and item of field groups.
    But i was not able to select the data based on this selection.
    i will attach my code here for reference.
    can anyone please help me how to use these filed symbols.
    If possible send me the document on Dynamic selections.
    the field i need to add is bkpf-bktxt
    TABLES:
      tcurx,
      lfa1,
      kna1,
      bhdgd,
      bkpf,
      bseg,
      bsega,
      b0sg,
      fimsg,
      sarkey,
      t001,
      vbset,
      sscrfields.
          Selektionsparameter                                           *
    begin_of_block 1.
    PARAMETERS:
      par_nbel       LIKE rfpdo-bpetnbel,  "Normale Belege
      par_vbel       LIKE rfpdo-epojvbel,  "Vorerfaßte Belege
      par_sbel       LIKE rfpdo-bpetsbel,  "Statistischen Belege
      par_mbel       LIKE rfpdo-epojmbel,  "Musterbelege
      par_dbel       LIKE rfpdo1-korbdbel. "Dauerbuchungsurbelege
    end_of_block 1.
    begin_of_block 2.
    PARAMETERS:
      par_summ       LIKE rfpdo1-allgsumm, "nur Summenausgabe
      par_hkto       LIKE rfpdo2-beljhkto, "Hauptbuch- statt Personenkonto
      par_altk       LIKE rfpdo1-allgaltk, "alternative Kontonummer
      par_lsep       LIKE rfpdo-allglsep,  "Listseparation
      par_mikf       LIKE rfpdo-allgmikf,  "Mikrofiche-Zeile
      par_line       LIKE rfpdo1-allgline. "Zusatztitel
    Eingaben für optische Archivierung
    SELECTION-SCREEN BEGIN OF LINE.
    PARAMETERS:     arc     LIKE rfpdo1-allgarch.
    SELECTION-SCREEN COMMENT 3(29) text-103 FOR FIELD arc.
    SELECTION-SCREEN POSITION POS_LOW.
    PARAMETERS:     arc_msg1(10) MODIF ID arc.
    SELECTION-SCREEN END OF LINE.
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN POSITION POS_LOW.
    PARAMETERS:     arc_msg2(10) MODIF ID arc.
    SELECTION-SCREEN END OF LINE.
    end_of_block 2.
    PARAMETERS:     arc_mem LIKE arc_params NO-DISPLAY.
          Felder und Feldleisten                                        *
    CONSTANTS:
      con_true       TYPE i                VALUE 1,
      con_false      TYPE i                VALUE 2,
      con_hash       TYPE i                VALUE 1,
      con_vendor     TYPE c                VALUE 'K',
      con_cust       TYPE c                VALUE 'D'.
    Global Data
    DATA: BEGIN OF hash_totals OCCURS 25,
             bukrs LIKE t001-bukrs,
             poper(7),
             dramt LIKE bseg-wrbtr,
             cramt LIKE bseg-wrbtr,
          END OF hash_totals.
    DATA:
      factor         TYPE i,
    Zähler
      cnt_bukrs(4)   TYPE p,               "Anzahl Buchungskreise
      cnt_max        LIKE sy-tfill,        "Maximum der CNT_Ti
      cnt_t0         LIKE sy-tfill,        "Anzahl Einträge in Ti
      cnt_t1         LIKE sy-tfill,
      cnt_t2         LIKE sy-tfill,
      cnt_t3         LIKE sy-tfill,
      cnt_t4         LIKE sy-tfill,
      cnt_t5         LIKE sy-tfill,
    Fehler
      err_altkt(1)   TYPE c,               "alt. Kontonummer nicht gefunden
    Flags
      flg_section    TYPE i,
      flg_vendr2     TYPE i,
      flg_vendr3     TYPE i,
      flg_color(1)   TYPE n,               "0 - intensified off
    Hilfsfelder
      hlp_belnr(10)  TYPE c,               "Anzeigefeld Belegnummer
      hlp_bstat      LIKE bkpf-bstat,      "Status vorerfaßter Belege
      hlp_buper(7)   TYPE c,               "Buchungsperiode mit '/'
      hlp_null(1)    TYPE p VALUE 0,       "Betrag Null
      hlp_sakan      LIKE ska1-sakan,      "Anzeigefeld Kontonummer
      hlp_wrshb(26)  TYPE c,               "FW-Betrag mit Währung in Klammer
      hlp_vnd_amt(43) TYPE c,
    Texte
      txt_line0(132) TYPE c,               "Überschriften
      txt_line1(132) TYPE c,
      txt_line2(132) TYPE c,
      txt_line(132)  TYPE c,               "Hilfstext
    Feldleisten
      BEGIN OF mikfi,                      "Information Mikrofiche-Zeile
        bstat        LIKE bkpf-bstat,
        bukrs        LIKE bkpf-bukrs,
        gjahr        LIKE bkpf-gjahr,
        belnr        LIKE bkpf-belnr,
      END OF mikfi.
          Interne Tabellen                                              *
    DATA:
    Belegkopfinformationen
      BEGIN OF t0 OCCURS 4,                "0 - allgemeine Angaben
        info(1)  TYPE n,                   "1 - vorerfaßter Beleg
      END OF t0,                           "2 - Referenz
                                                                "3 - Storno
                                           "4 - gelöschter vorerfaßter Beleg
                                           "5 - ersetzter vorerfaßter Beleg
                                           "6 - Ausgleichsbeleg
                                           "7 - zurückgenommener Ausgleich
    Personenkonteninformationen je Beleg
      BEGIN OF t1 OCCURS 10,
        koart    LIKE bseg-koart,          "Kontoart
        ktonr    LIKE bseg-kunnr,          "Kontonummer(Debitor/Kreditor)
        bschl    LIKE bseg-bschl,          "Buchungsschlüssel
        xnegp    LIKE bseg-xnegp,          "Negativbuchung
        umskz    LIKE bseg-umskz,          "Sonderumsatzkennzeichen
        zlspr    LIKE bseg-zlspr,          "Payment Block Key - CR 21709
        dmshb    LIKE bsega-dmshb,         "Soll-Haben Betrag in Hauswährung
        wrshb    LIKE bsega-dmshb,         "Betrag in Fremdwährung
        xfwae(1) TYPE c,                   "X - Fremdwährungsinformation
        name1    LIKE lfa1-name1,          "Customer/ Vendor Name
      END OF t1,
    Steuerinformationen je Beleg
      BEGIN OF t2 OCCURS 10,
        mwskz    LIKE bseg-mwskz,          "Mehrwertsteuerkennzeichen
        dmshb    LIKE bsega-dmshb,         "Soll-Haben Betrag in Hauswährung
      END OF t2,
    Sachkonteninformationen je Beleg
      BEGIN OF t3 OCCURS 20,
        mwskz    LIKE bseg-mwskz,          "Mehrwertsteuerkennzeichen
        bschl    LIKE bseg-bschl,          "Buchungsschlüssel
        xnegp    LIKE bseg-xnegp,          "Negativbuchung
        koart    LIKE bseg-koart,          "Kontoart
        hkont    LIKE bseg-hkont,          "Hauptbuchkonto
        dmshb    LIKE bsega-dmshb,         "Soll-Haben Betrag in Hauswährung
        kostl    LIKE bseg-kostl,          "Cost Center
        prctr    LIKE bseg-prctr,          "Profit Center
      END OF t3,
    Sonderhauptbuchbeträge für Debitoren (nur Ausgabe)
      BEGIN OF t4 OCCURS 5,
        umskz         LIKE bseg-umskz,     "Sonderumsatzkennzeichen
        dmsol(9)      TYPE p,              "Soll-Betrag Hauswährung
        dmhab(9)      TYPE p,              "Haben-Betrag Hauswährung
      END OF t4,
    Sonderhauptbuchbeträge für Kreditoren (nur Ausgabe)
      BEGIN OF t5 OCCURS 5,
        umskz         LIKE bseg-umskz,     "Sonderumsatzkennzeichen
        dmsol(9)      TYPE p,              "Soll-Betrag Hauswährung
        dmhab(9)      TYPE p,              "Haben-Betrag Hauswährung
      END OF t5,
    Summeninformationen je Buchungskreis
      BEGIN OF tbukrs OCCURS 20,
        bstat         LIKE bkpf-bstat,     "Belegstatus
        bukrs         LIKE bkpf-bukrs,     "Buchungskreis
    START OF CHANGE FOR CR63816 by OS0794 on 01/29/2008
        bktxt         LIKE bkpf-bktxt,
    END OF CHANGE FOR CR63816 by OS0794 on 01/29/2008
        gjahr         LIKE bkpf-gjahr,     "Buchungsjahr
        monat         LIKE bkpf-monat,     "Buchungsmonat
        dmsol(9)      TYPE p,              "Soll-Betrag Hauswährung
        dmhab(9)      TYPE p,              "Haben-Betrag Hauswährung
        waers         LIKE t001-waers,     "Währungsschlüssel (nur Ausgabe)
      END OF tbukrs,
    Sonderhauptbuchinformationen je Buchungskreis
      BEGIN OF tbukrs_u OCCURS 20,
        bstat         LIKE bkpf-bstat,     "Belegstatus
        bukrs         LIKE bkpf-bukrs,     "Buchungskreis
    START OF CHANGE FOR CR63816 by OS0794 on 01/29/2008
        bktxt         LIKE bkpf-bktxt,
    END OF CHANGE FOR CR63816 by OS0794 on 01/29/2008
        gjahr         LIKE bkpf-gjahr,     "Buchungsjahr
        monat         LIKE bkpf-monat,     "Buchungsmonat
        koart         LIKE bseg-koart,     "Kontoart
        umskz         LIKE bseg-umskz,     "Sonderumsatzkennzeichen
        dmsol(9)      TYPE p,              "Soll-Betrag Hauswährung
        dmhab(9)      TYPE p,              "Haben-Betrag Hauswährung
        waers         LIKE t001-waers,     "Währungsschlüssel (nur Ausgabe)
      END OF tbukrs_u,
    Summeninformationen je Hauswährung
      BEGIN OF twaers OCCURS 10,
        bstat         LIKE bkpf-bstat,     "Belegstatus
        waers         LIKE t001-waers,     "Hauswährungsschlüssel
        gjahr         LIKE bkpf-gjahr,     "Buchungsjahr
        monat         LIKE bkpf-monat,     "Buchungsmonat
        dmsol(9)      TYPE p,              "Soll-Betrag Hauswährung
        dmhab(9)      TYPE p,              "Haben-Betrag Hauswährung
      END OF twaers,
    Sonderhauptbuchinformationen je Hauswährung
      BEGIN OF twaers_u OCCURS 20,
        bstat         LIKE bkpf-bstat,     "Belegstatus
        waers         LIKE t001-waers,     "Währungsschlüssel
        gjahr         LIKE bkpf-gjahr,     "Buchungsjahr
        monat         LIKE bkpf-monat,     "Buchungsmonat
        koart         LIKE bseg-koart,     "Kontoart
        umskz         LIKE bseg-umskz,     "Sonderumsatzkennzeichen
        dmsol(9)      TYPE p,              "Soll-Betrag Hauswährung
        dmhab(9)      TYPE p,              "Haben-Betrag Hauswährung
      END OF twaers_u,
    Fehlerprotokoll im Batch
      BEGIN OF tfimsg OCCURS 10.
            INCLUDE STRUCTURE fimsg.
    DATA END OF tfimsg.
          Strukturen für optische Archivierung                          *
    DATA BEGIN OF info OCCURS 10.
            INCLUDE STRUCTURE bhinf.
    DATA END OF info.
    DATA:
      arc_save LIKE arc_params,
      arc_valid.
          Feldgruppen                                                   *
    FIELD-GROUPS: header, daten.
    INSERT:
      bkpf-bukrs                           "Buchungskreis
      bkpf-bktxt                           "Change by OS0794
      bkpf-bstat                           "Belegstatus
      bkpf-gjahr                           "Geschäftsjahr
      bkpf-belnr                           "Belegnummer
      bseg-buzei                           "Buchungszeile
    INTO header.
    INSERT
      bkpf-blart                           "Belegart
      bkpf-bktxt                           "Change by OS0794
      bkpf-budat                           "Buchungsdatum
      bkpf-stblg                           "Stornobelegnummer
      bkpf-waers                           "Währungsschlüssel
      bkpf-xblnr                           "Referenzangabe
      bseg-bschl                           "Buchungsschlüssel
      bseg-xnegp                           "Negativbuchung
      bseg-zlspr                           "Payment Block Key - CR 21709
      bseg-hkont                           "Hauptbuchkonto
      bseg-koart                           "Kontoart
      bseg-kunnr                           "Debitornummer
      bseg-lifnr                           "Kreditornummer
      bseg-mwart                           "Mehrwertsteuerart (A oder V)
      bseg-mwskz                           "Mehrwertsteuerkennzeichen
      bseg-umskz                           "Sonderhauptbuch-Kennzeichen
      bsega-dmshb                          "S/H-Betrag in Hauswährung
      bsega-mdshb                          "Umsatzsteuerbetrag in Hauswährg
      bsega-wrshb                          "S/H-Betrag in Fremdwährung
      hlp_bstat                            "Status vorerfaßter Belege bzw.
      bseg-kostl
      bseg-prctr
      bkpf-monat
    INTO daten.                            "Status von Belegen ohne Zeilen
          Vorschlagswerte                                               *
    INITIALIZATION.
      get_frame_title: 1,2.
      par_nbel = 'X'.
      par_sbel = space.
      par_mbel = space.
      par_dbel = space.
      par_vbel = 'X'.
          Archivinformationen nur fuer Ausgabe                          *
    AT SELECTION-SCREEN OUTPUT.
      LOOP AT SCREEN.
        IF screen-group1 = 'ARC'.
          screen-input = '0'.
          MODIFY SCREEN.
        ENDIF.
      ENDLOOP.
          Prüfung und Korrektur der eingegebenen Daten                  *
    AT SELECTION-SCREEN ON arc.
      IF arc <> ' ' AND arc_mem(20) = space.
        CALL FUNCTION 'GET_ARCHIVE_PARAMETERS'
          EXPORTING
            in_parameters  = arc_save
            printer        = '    '
          IMPORTING
            out_parameters = arc_mem
            valid          = arc_valid
          EXCEPTIONS
            OTHERS         = 04.
        IF arc_valid <> 'X' OR arc_mem = space.
          CLEAR arc_mem.
          MESSAGE e999 WITH text-102.
        ENDIF.
        arc_msg1 = arc_mem(10).
        arc_msg2 = arc_mem+10(10).
      ENDIF.
      IF arc = ' '.
        CLEAR arc_mem.
        arc_msg1 = arc_msg2 = space.
      ENDIF.
      arc_save = arc_mem.
    AT SELECTION-SCREEN ON arc_msg1.
      arc_msg1 = arc_mem(10).
    AT SELECTION-SCREEN ON arc_msg2.
      arc_msg2 = arc_mem+10(10).
    AT SELECTION-SCREEN.
      IF par_nbel EQ space AND
         par_mbel EQ space AND
         par_dbel EQ space AND
         par_sbel EQ space AND
         par_vbel EQ space.
        SET CURSOR FIELD 'PAR_NBEL'.
        MESSAGE e111.
      ENDIF.
    optische Archivierung
      IF arc <> ' ' AND par_mikf <> ' '.
        CLEAR arc_mem.
        MESSAGE e999 WITH text-100.
      ENDIF.
      IF arc <> ' ' AND par_lsep <> ' '.
        CLEAR arc_mem.
        MESSAGE e999 WITH text-101.
      ENDIF.
      IF arc = 'X' AND sscrfields-ucomm = 'PRIN'.
        sscrfields-ucomm = 'ONLI'.
        sy-pdest = 'LP01'.                 "wegen Abfrage in Batch-Heading
      ENDIF.
          Vorbelegungen                                                 *
    START-OF-SELECTION.
      bhdgd-lines = sy-linsz.
      bhdgd-repid = sy-repid.
      bhdgd-uname = sy-uname.
      bhdgd-separ = par_lsep.
      bhdgd-domai = 'BUKRS'.
      IF arc = 'X'.
        bhdgd-miffl = 'A'.
      ENDIF.
      IF par_mikf = 'X'.
        bhdgd-miffl = 'X'.
      ENDIF.
    Initialisierung für optisches Archiv
      PERFORM open_archive(rsbtchh0) USING arc_mem.
      info-name = 'BKPF-BSTAT'. info-len = space. APPEND info.
      info-name = 'BKPF-BUKRS'. info-len = space. APPEND info.
      info-name = 'BSEG-GJAHR'. info-len = space. APPEND info.
      info-name = 'BKPF-BELNR'. info-len = space. APPEND info.
      info-name = 'BKPF-BKTXT'. info-len = space. APPEND info.
      PERFORM start_archive(rsbtchh0) TABLES info.
      b0sg-xstan = par_nbel.
      b0sg-xstam = par_mbel.
      b0sg-xstad = par_dbel.
      b0sg-xstas = par_sbel.
      b0sg-xstaa = 'X'.
      IF par_vbel EQ 'X'.
        b0sg-xstav = 'Z'.
      ENDIF.
          Selektion                                                     *
    GET bkpf FIELDS blart bstat budat monat stblg waers xblnr bktxt.
      CLEAR hlp_bstat.
      IF 'ABVWZ' CA bkpf-bstat.
        hlp_bstat = bkpf-bstat.
        CLEAR bkpf-bstat.
        IF 'ABWZ' CA hlp_bstat.
          CLEAR: bseg, bsega.
          IF par_summ EQ space.
            EXTRACT daten.
          ENDIF.
          PERFORM summe_merken.
        ENDIF.
      ENDIF.
    GET bseg.
      IF par_summ EQ space.
        EXTRACT daten.
      ENDIF.
      PERFORM summe_merken.
    GET bkpf LATE.
      PERFORM vorerfasste_steuer_merken.
          Seitenkopf                                                    *
    TOP-OF-PAGE.
      PERFORM batch-heading(rsbtchh0).
      ULINE.
      IF flg_section <> con_hash.
        FORMAT COLOR 1 INTENSIFIED OFF.
        WRITE    / txt_line0.
        ULINE.
        FORMAT COLOR 1 INTENSIFIED.
        WRITE:   / txt_line1,
                 / txt_line2.
      ELSE.
        FORMAT COLOR 1 INTENSIFIED OFF.
        WRITE: / sy-vline NO-GAP,
                 'Hash Totals'(205),
           132   sy-vline.
        ULINE.
        FORMAT COLOR 1 INTENSIFIED.
        WRITE:   /     sy-vline NO-GAP,
                  (10) 'CoCd'(200),
                  (07) 'Period'(201),
                       sy-vline,
                  (16) 'Debit Amount'(202),
                  (16) 'Credit Amount'(203),
                       sy-vline,
                  (16) 'Total'(204).
      ENDIF.
      ULINE.
          Sortieren der Daten                                           *
    END-OF-SELECTION.
      DESCRIBE TABLE tbukrs LINES sy-tfill.
      IF sy-tfill EQ 0.
        CALL FUNCTION 'POPUP_NO_LIST'.
      ENDIF.
      SORT.
      SORT tbukrs.
          Belegjournal                                                  *
      LOOP.
    *-- Neuer Buchungskreis -
        AT NEW bkpf-bukrs.
          SELECT SINGLE * FROM t001 WHERE bukrs EQ bkpf-bukrs.
          IF sy-subrc NE 0.
            IF sy-batch EQ space.
              MESSAGE a101 WITH bkpf-bukrs.
            ELSE.
              MESSAGE s101 WITH bkpf-bukrs.
              STOP.
            ENDIF.
          ENDIF.
          bhdgd-bukrs = bkpf-bukrs.
          bhdgd-werte = bkpf-bukrs.
          PERFORM new-section(rsbtchh0).
          PERFORM titel_fuellen USING '5'.
        ENDAT.
    *-- Neuer Belegstatus -
        AT NEW bkpf-bstat.
          PERFORM new_page USING bkpf-bstat.
          flg_color = 1.
        ENDAT.
    *-- Neue Belegnummer -
        AT NEW bkpf-belnr.
          REFRESH: t0, t1, t2, t3.
          PERFORM belegkopf_merken.
          mikfi-bstat = bkpf-bstat.
          mikfi-bukrs = bkpf-bukrs.
          mikfi-gjahr = bkpf-gjahr.
          mikfi-belnr = bkpf-belnr.
          bhdgd-grpin = mikfi.
        ENDAT.
    *-- Belegzeile -
        PERFORM belegzeile_merken.
    *-- Ende einer Belegnummer -
        AT END OF bkpf-belnr.
          PERFORM beleg_schreiben.
          ULINE.
        ENDAT.
    *-- Ende eines Buchungskreises -
        AT END OF bkpf-bukrs.
          PERFORM titel_fuellen USING '4'.
          PERFORM buchungskreis_schreiben USING bkpf-bukrs.
        ENDAT.
      ENDLOOP.
          Summenblätter                                                 *
      bhdgd-bukrs = '    '.
      bhdgd-werte = '    '.
      PERFORM new-section(rsbtchh0).
      PERFORM titel_fuellen USING '4'.
      PERFORM buchungskreis_schreiben USING '    '.
      PERFORM hauswaehrung_schreiben.
          Print Hash Totals                                             *
      flg_section = con_hash.
      NEW-PAGE.
      PERFORM prt_hash TABLES hash_totals.
          Fehlerprotokoll                                               *
      CALL FUNCTION 'FI_MESSAGE_CHECK'
        EXCEPTIONS
          no_message = 4.
      IF sy-subrc = 0.
        IF sy-batch EQ space.
          PERFORM titel_fuellen USING '6'.
          NEW-PAGE.
          FORMAT COLOR 6 INTENSIFIED.
          CALL FUNCTION 'FI_MESSAGE_SORT'.
          CALL FUNCTION 'FI_MESSAGE_PRINT'
            EXPORTING
              i_xskip = 'X'.
        ELSE.
          CALL FUNCTION 'FI_MESSAGE_GET'
            TABLES
              t_fimsg = tfimsg.
          LOOP AT tfimsg.
            MESSAGE ID tfimsg-msgid TYPE tfimsg-msgty NUMBER tfimsg-msgno
              WITH tfimsg-msgv1 tfimsg-msgv2 tfimsg-msgv3 tfimsg-msgv4.
          ENDLOOP.
        ENDIF.
      ENDIF.
           U N T E R P R O G R A M M E                                  *
                0. TITEL_FUELLEN                                        *
                1. NEW_PAGE                                             *
                2. SUMME_MERKEN                                         *
                3. VORERFASSTE_STEUER_MERKEN                            *
                4. BELEGKOPF_MERKEN                                     *
                5. BELEGZEILE_MERKEN                                    *
                6. BELEG_SCHREIBEN                                      *
                7. BUCHUNGSKREIS_SCHREIBEN                              *
                8. HAUSWAEHRUNG_SCHREIBEN                               *
                9. SUMMENZEILE_SCHREIBEN                                *
               10. KONTONUMMER                                          *
    0.   FORM TITEL_FUELLEN                                            *
          Ersetzt das Global &CCCU durch die Buchungskreiswährung       *
          F00_TEXT ist 4, 5 oder 6, je nach Gruppe der Textelemente     *
    FORM titel_fuellen USING f00_text.
      DATA:
        BEGIN OF txt_502,
         T1(49) TYPE C, "CR 21709
         W1(23) TYPE C, "CR 21709
          t1(50) TYPE c,                                        "CR 21709
          w1(22) TYPE c,                                        "CR 21709
          t2(6)  TYPE c,
          w2(15) TYPE c,
          t3(21) TYPE c,
          w3(16) TYPE c,
          t4(2)  TYPE c,
        END OF txt_502.
      CASE f00_text.                       "Textelemente
        WHEN '4'.                          "- für die Summenliste
          txt_line0 = text-400.
          txt_line1 = text-401.
          txt_line2 = text-402.
        WHEN '5'.                          "- für die Einzelpostenliste
          txt_line0 = text-500.
          txt_line1 = text-501.
          txt_line2 = text-502.
          IF par_hkto EQ 'X'.
            txt_line1+33(10) = text-505.
            txt_line2+33(10) = text-506.
          ENDIF.
          txt_502   = txt_line2.
          REPLACE '&CCCU' WITH t001-waers INTO:
            txt_502-w1, txt_502-w2, txt_502-w3.
          CONDENSE:
            txt_502-w1, txt_502-w2, txt_502-w3.
          WRITE:
            txt_502-w1 TO txt_502-w1 RIGHT-JUSTIFIED,
            txt_502-w2 TO txt_502-w2 RIGHT-JUSTIFIED,
            txt_502-w3 TO txt_502-w3 RIGHT-JUSTIFIED.
          txt_line2 = txt_502.
        WHEN '6'.                          "- für die Fehlerliste
          txt_line0 = text-600.
          txt_line1 = text-601.
          txt_line2 = space.
        WHEN OTHERS.                       "- initialisieren
          txt_line0 = space.
          txt_line1 = space.
          txt_line2 = space.
      ENDCASE.
    ENDFORM.                    "TITEL_FUELLEN
    1.   FORM NEW_PAGE                                                 *
          Initialisierungen für BATCH-HEADING Routine                   *
          F01_BSTAT steuert den Aufbau des Reporttitels                 *
    FORM new_page USING f01_bstat.
      CASE f01_bstat.                      "Reporttitel
        WHEN 'D'.                          "- für Dauerbuchungsurbelege
          bhdgd-line1 = text-001.
        WHEN 'M'.                          "- für Musterbelege
          bhdgd-line1 = text-002.
        WHEN 'S'.                          "- für statistische Belege
          bhdgd-line1 = text-003.
        WHEN OTHERS.                       "- für normale/vorerfaßte Belege
          bhdgd-line1 = sy-title.
      ENDCASE.
      bhdgd-line2 = par_line.
      bhdgd-inifl = 0.
      NEW-PAGE.
    ENDFORM.                    "NEW_PAGE
    2.   FORM SUMME_MERKEN                                             *
          Merken der Summeninformation                                  *
    FORM summe_merken.
      CLEAR tbukrs.
      tbukrs-bstat = bkpf-bstat.
      tbukrs-bukrs = bkpf-bukrs.
      tbukrs-bktxt = bkpf-bktxt.
      tbukrs-gjahr = bkpf-gjahr.
      tbukrs-monat = bkpf-monat.
      tbukrs-dmsol = bsega-dmsol.
      tbukrs-dmhab = bsega-dmhab.
      IF 'DK' CA bseg-koart.
        MOVE-CORRESPONDING tbukrs TO tbukrs_u.
        tbukrs_u-koart   = bseg-koart.
        tbukrs_u-umskz   = bseg-umskz.
        tbukrs_u-dmsol   = bsega-dmsol.
        tbukrs_u-dmhab   = bsega-dmhab.
        COLLECT tbukrs_u.
        tbukrs_u-monat   = 0.              "Summe für das Geschäftsjahr
        COLLECT tbukrs_u.
      ENDIF.
      COLLECT tbukrs.
    ENDFORM.                    "SUMME_MERKEN
    3.   FORM VORERFASSTE_STEUER_MERKEN                                *
          Nachlesen der Steuerzeilen vorerfaßter Belege                 *
          Gefüllt wird TBUKRS und der Extrakt                           *
    FORM vorerfasste_steuer_merken.
      CHECK hlp_bstat EQ 'V'.
      SELECT * FROM vbset
        WHERE ausbk EQ bkpf-bukrs
          AND belnr EQ bkpf-belnr
          AND gjahr EQ bkpf-gjahr.
        CHECK vbset-hwste NE 0.
        CLEAR: bseg, bsega.
        bseg-koart    = 'S'.
        bseg-mwart    = 'V'.               "oder 'A', nur zum Füllen von T2
        bseg-mwskz    = vbset-mwskz.
        IF vbset-shkzg EQ 'S'.
          bsega-dmsol = vbset-hwste.
          bsega-dmshb = vbset-hwste.
        ELSE.
          bsega-dmhab = vbset-hwste.
          bsega-dmshb = - vbset-hwste.
        ENDIF.
        IF par_summ EQ space.
          EXTRACT daten.
        ENDIF.
        PERFORM summe_merken.
      ENDSELECT.
    ENDFORM.                    "VORERFASSTE_STEUER_MERKEN
    4.   FORM BELEGKOPF_MERKEN                                         *
          Je Beleg werden gefüllt:                                      *
          T0 - Informationsflag                                         *
    FORM belegkopf_merken.
      t0-info = 0.                         "Belegkopf
      APPEND t0.
      CASE hlp_bstat.
        WHEN 'A'.
          t0-info = 6.                     "Ausgleichsbeleg
          APPEND t0.
        WHEN 'B'.
          t0-info = 7.                     "zurückgen. Ausgleichsbeleg
          APPEND t0.
        WHEN 'V'.
          t0-info = 1.                     "vorerfaßter Beleg
          APPEND t0.
        WHEN 'W'.
          t0-info = 5.                     "ersetzter vorerfaßter Beleg
          APPEND t0.
        WHEN 'Z'.
          t0-info = 4.                     "gelöschter vorerfaßter Beleg
          APPEND t0.
      ENDCASE.
      IF bkpf-xblnr NE space AND hlp_bstat NA 'BWZ'.
        t0-info = 2.                       "Referenz
        APPEND t0.
      ENDIF.
      IF bkpf-stblg NE space.
        t0-info = 3.                       "Storno
        APPEND t0.
      ENDIF.
      SORT t0.
    ENDFORM.                    "BELEGKOPF_MERKEN
    5.   FORM BELEGZEILE_MERKEN                                        *
          Je Beleg werden gefüllt:                                      *
          T1 - Personenkonteninformation                                *
          T2 - Steuerinformation (nicht bei vorerfaßten Belegen)        *
          T3 - Sachkonteninformation                                    *
    FORM belegzeile_merken.
    Vendors/ Customers
      IF bseg-koart CA 'DK'.
        t1-koart   = bseg-koart.
        IF par_hkto EQ 'X'.
          t1-ktonr = bseg-hkont.
        ELSEIF bseg-koart EQ 'K'.
          t1-ktonr = bseg-lifnr.
        ELSE.
          t1-ktonr = bseg-kunnr.
        ENDIF.
        t1-bschl   = bseg-bschl.
        t1-umskz   = bseg-umskz.
        t1-xnegp   = bseg-xnegp.
        t1-zlspr   = bseg-zlspr.                                "CR 21709
        t1-dmshb   = bsega-dmshb.
        t1-wrshb   = bsega-wrshb.
        t1-xfwae   = space.
        APPEND t1.
      Read the vendor description.
        IF bseg-koart = con_vendor.
          flg_vendr2 = con_true.
          flg_vendr3 = con_true.
          CLEAR lfa1-name1.
          SELECT SINGLE name1
          INTO   lfa1-name1
          FROM   lfa1
          WHERE  lifnr = bseg-lifnr.
        ELSEIF bseg-koart = con_cust.
          CLEAR kna1-name1.
          SELECT SINGLE name1
          INTO   kna1-name1
          FROM   kna1
          WHERE  kunnr = bseg-kunnr.
        ENDIF.
        IF bkpf-waers EQ t001-waers.
          CLEAR t1.
        ENDIF.
        t1-xfwae = 'X'.
        t1-name1 = lfa1-name1.
        IF t1-name1 IS INITIAL.
          t1-name1 = kna1-name1.
        ENDIF.
        APPEND t1.
        CLEAR:
           kna1-name1,
           lfa1-name1.
        CLEAR t1.
      Save the hash total amounts
        CLEAR tcurx-currdec.
        SELECT SINGLE currdec
        INTO   tcurx-currdec
        FROM   tcurx
        WHERE  currkey = bkpf-waers.
        IF tcurx-currdec = 1.
          factor = 10.
        ELSE.
          factor = 100.
        ENDIF.
        CLEAR hash_totals.
        hash_totals-bukrs = bkpf-bukrs.
        CONCATENATE bkpf-monat '/' bkpf-gjahr INTO hash_totals-poper.
        IF bsega-wrshb < 0.
          hash_totals-cramt = bsega-wrshb * factor.
        ELSE.
          hash_totals-dramt = bsega-wrshb * factor.
        ENDIF.
        COLLECT hash_totals.
    Tax accounts
      ELSEIF bseg-mwart CA 'AV'.
        t2-mwskz   = bseg-mwskz.
        t2-dmshb   = bsega-dmshb.
        APPEND t2.
        IF flg_vendr2 = con_true.
          flg_vendr2 = con_false.
          CLEAR t2.
          APPEND t2.
        ENDIF.
    GL Accounts
      ELSEIF hlp_bstat NA 'ABWZ'.
        t3-mwskz   = bseg-mwskz.
        t3-bschl   = bseg-bschl.
        t3-xnegp   = bseg-xnegp.
        t3-koart   = bseg-koart.
        t3-hkont   = bseg-hkont.
        t3-dmshb   = bsega-dmshb.
        APPEND t3.
        IF flg_vendr3 = con_true
        OR NOT bseg-kostl IS INITIAL
        OR NOT bseg-prctr IS INITIAL.
          flg_vendr3 = con_false.
          CLEAR t3.
          t3-kostl = bseg-kostl.
          t3-prctr = bseg-prctr.
          APPEND t3.
          CLEAR t3.
        ENDIF.
      ENDIF.
    ENDFORM.                    "BELEGZEILE_MERKEN
    6.   FORM BELEG_SCHREIBEN                                          *
          Ausgabe der Belginformationen                                 *
    FORM beleg_schreiben.
      DATA:
         len TYPE i.
    Berechnung der benötigten Zeilen pro Beleg
      DESCRIBE TABLE:
        t0 LINES cnt_t0,
        t1 LINES cnt_t1,
        t2 LINES cnt_t2,
        t3 LINES cnt_t3.
      cnt_max = cnt_t0.
      IF cnt_max LT cnt_t1.
        cnt_max = cnt_t1.
      ENDIF.
      IF cnt_max LT cnt_t2.
        cnt_max = cnt_t2.
      ENDIF.
      IF cnt_max LT cnt_t3.
        cnt_max = cnt_t3.
      ENDIF.
      ADD 1 TO cnt_max.
      IF cnt_max LE 10.
        RESERVE cnt_max LINES.
      ELSE.
        RESERVE 5 LINES.
      ENDIF.
      SUBTRACT 1 FROM cnt_max.
    Farbe setzen
      IF flg_color EQ 0.
        FORMAT COLOR 2 INTENSIFIED OFF.
        flg_color = 1.
      ELSE.
        FORMAT COLOR 2 INTENSIFIED.
        flg_color = 0.
      ENDIF.
    Index fuer optische Archivierung
      PERFORM new-group(rsbtchh0).
      DO cnt_max TIMES.
      Belegkopfinformationen
        WRITE     /1 sy-vline NO-GAP.
        IF sy-index LE cnt_t0.
          READ TABLE t0 INDEX sy-index.
          CASE t0-info.
            WHEN 0.                        "Belegkopf
              hlp_belnr = bkpf-belnr.      "Belegnr. mit führenden Nullen
            Referenz auf Originalbeleg
              PERFORM start_doc_reference(rsbtchh0)
                USING bkpf-bukrs bkpf-belnr bkpf-gjahr bkpf-bktxt. " change*
              WRITE:
                     bkpf-bukrs,
                     hlp_belnr,
                     bkpf-blart,
                     bkpf-budat DD/MM/YYYY.
            Ende der Referenz auf Originalbeleg
              PERFORM end_doc_reference(rsbtchh0).
            WHEN 1.                        "Vorerfaßter Beleg
              WRITE:
                (29) text-507.
            WHEN 2.                        "Referenz
              WRITE:
                (12) text-503,
                     bkpf-xblnr.
            WHEN 3.                        "Storno
              WRITE:
                (12) text-504,
                     bkpf-stblg.
            WHEN 4.                        "Gelöschter vorerfaßter Beleg
              WRITE:
                (29) text-507,
                (40) text-508.
            WHEN 5.                        "Ersetzter vorerfaßter Beleg
              txt_line = text-509.
              REPLACE:
                '&BLN' WITH bkpf-xblnr(10) INTO txt_line,
                '&GJR' WITH bkpf-xblnr+10  INTO txt_line.
              WRITE:
                (29) text-507,
                (40) txt_line.
            WHEN 6.                        "Ausgleichsbeleg
              WRITE:                       "
                (29) text-510.             "
            WHEN 7.                        "zurückgen. Ausgleichsbeleg
              WRITE:                       "
                (29) text-511.             "
          ENDCASE.
        ENDIF.
      Personenkonteninformationen
      Subledger Account Information
        WRITE  31(1) sy-vline NO-GAP.
      Internal tables T0 - T5 hold data for each section.
        IF sy-index LE cnt_t1.
          READ TABLE t1 INDEX sy-index.
          IF par_hkto EQ 'X'.
            PERFORM kontonummer USING t1-ktonr hlp_sakan.
          ELSE.
            hlp_sakan = t1-ktonr.
          ENDIF.
          IF t1-xfwae EQ space.
            IF t1-xnegp = 'X'.
              t1-xnegp = '-'.
            ENDIF.
          Write the vendor number.
            WRITE:   t1-koart,
                     hlp_sakan,
                     t1-bschl NO-GAP.
            IF t1-umskz IS INITIAL.
              WRITE:    t1-xnegp NO-GAP,
                        t1-umskz.
            ELSE.
              WRITE:    t1-umskz NO-GAP,
                        t1-xnegp.
            ENDIF.
            WRITE: t1-zlspr. "CR 21709 / 23588
            WRITE: (22) t1-dmshb CURRENCY t001-waers.
          ELSE.
          Write the document currency, amount and the
          vendor/ customer

    Hi,
    Please see documentation of enhancement MM06E005 (transaction SMOD).          
    Userexit EXIT_SAPMM06E_016 is a component of enhancement MM06E005.            
    With that enhancement, you can                                                
      -   Maintain/supply your own customer fields                                
      -   Update your own customer-specific tables                                
    You cannot:                                                                   
      -   Change standard fields                                                  
      -   Change data that depends on the document header in the items            
      -   Change data that depends on an item in the document header                                                                               
    Please have a look at Business Add-In (BAdI) ME_PROCESS_PO_CUST.              
    Regards,
    Edit

Maybe you are looking for