Summary, decode REP 1213

Hello Everyone!
We are trying display data from a table;
by date, year
by categories
summary of date, year
summary of categories
We used Summary, Summary column, decode, and calculations for requirements.
After modify in report editor, the REP 1213 appeared so that we have to start over again.
We are tesing Data link now.
If you knew better way, please share with us.
Thanks in advance,
S!G
Edited by: Sea!Gull on Aug 26, 2011 8:35 AM

Describe the cause and remedyCause:     The source column for the field is in a group below that of the repeating frame which encloses it.
Action:     Move the field into a repeating frame whose source group is at or above the group that contains the field's source column. Otherwise, move the field's source column into the enclosing repeating frame's group, if possible.
(that was just a copy-paste from the Help. You could have done that yourself).

Similar Messages

  • REP-1213 Error

    Hi, I have created a Formula Column with PL/SQL function in a group query to generate a report. When I call this Formula Column from the report, an error occurs:
    "REP-1213 Field 'F_1' references column 'Trade_Disc' at a frequency below its group"
    How to I correct this error?
    Thank you.
    Joey

    Hi, I refer this problem to the metalink (Doc ID: 1004004.6). But can someone tell me what does it mean by "detail field" in this statement:
    "Make sure no detail field is referenced on the repeating frame of a master. It should be on its own repeating frame otherwise the frequency difference between the two will give REP-1213. This is also true for summary field on detail column."
    Does this mean by the 'F_1' field is the detailed field? Please advise.
    P/S: The 'Trade_Disc' formula column is in the main group.
    Joey

  • REP - 1213 Reference column frequency below its group

    Hi,
    In a report (6i) it is showing Error like "REP - 1213 field F_SUM_COLLECTIONS_RATIO
    Reference column CS_COLLECTION_RATIO at a frequency below its group"
    As I know this is a problem of repeating frame problem:-
    1. How can I check this error ? And How can resolve this problem?
    Note:-
    In this sales_ratio,collection_ratio,sales?coll._ratio I added Corr. formula columns and create summary
    columns corr. to each.
    This summary columns having problem.

    Good morning,
    What I have found is that every time I have this problem, it is because during the manipulation of report items, I have inadvertently moved an item outside of its parent block.
    If you expand the size of your report layout editor (control-key and PLUS key [ ctrl+]), you can usually see where the item has strayed outside of its parent report block.
    I hope this helps,
    Don.
    REWARDS: Please remember to mark helpful or correct posts on the forum, not just for my answers but for everyone! :)

  • REP-1213: Field  references column at a frequency below its group

    Is there a way of making a field which is on a lower level group to be displayed in a group which is at a higher level in the report?
    I have a field which is within a lower level group on a report and I want it to appear as a header, within a group which is a level above its own group. The field should remain in its original group but should not appear on the report as a column within its original group but should appear as part of the heading.
    I have tried it and got error REP-1213: Field references column at a frequency below its group, but how can I achieve what I want to do without getting this error? Is there a way of showing this field on the header without actually moving it into the header group? Should I create an alias or a function or what and how?
    Please help.

    user8655468 wrote:
    Sorry, I don't seem to get you. MY report has 2 repeating groups. The first group has student_name, course_code, course_name and the 2nd group has academic_year, module_name, module_code and module_grade. Academic_year which is in the 2nd group has to appear as a heading together with the items in the first group but it can not be moved from its original group as it goes together with modules. The report displays a history of a student's modules from 1st year to current year so the Academic year on the header will have to show the current Academic year for a student.
    I don't understand how I should use a summary column to achieve what I want to do. Please can you explain further. Thanks.I think you know about summary column. If your academic year is number filed, you can use it at summary column. Where summary function is sum. You take this summary column at 1st group and select source from 2nd group. Then display it at 1st frame.
    Hope this will help you..
    If someone's response is helpful or correct, please mark it accordingly.

  • CUSTOM REPORT PROBLEM - REP-1213

    I am a student trying to complete a project. I developed a
    "custom" report form which uses 5 tables to generate the report.
    I have entered the 'fields' at various locations on the report
    form and when I run the report I get the following error message:
    "REP-1213: Field 'client_id' references column 'CLIENT_ID' at a
    frequency below its group."
    I have presented this problem to my instructor who does not have
    a solution to resolve this problem for me. Is there a solution
    for this? Or ... does Oracle not allow for 'custom designing'
    of reports? How does someone develop a custom made invoice or
    other report for a client without encountering these problems?
    Anybody's assistance in this matter would be greatly appreciated.
    BO
    null

    Here is some information that may be of help. This is straight
    from Oracle. read the part on FREQUENCY ERRORS carefully.
    You may also retrieve this document from:
    otn home page --> support --> technicial bulletions -->
    sql*reportwriter --> 9006913.61
    P.S. reportwriter frames have kicked manny asses!!
    Good luck.
    Document ID: 9006913.61
    Title: Understanding Frames
    Revision Number 0
    Product: Oracle Reports
    Platform: GENERIC
    Abstract: This document provides a better
    understanding
    of frames and the layering concept.
    Also
    discusses frequency errors.
    Keywords: REPEATING;FRAME;VARIABLE;FIXED;EXPAND;
    CONTRACT;FREQUENCY;
    INTRODUCTION
    There are two types of frames: Repeating frames and non-repeating
    frames.
    Each is a visual representation of actual 3GL code that underlies
    the action
    of fetching and printing the rows selected from tables.
    Non-repeating frames
    act as containers and can be mapped back to the pseudocode: BEGIN
    and END.
    Repeating frames are representations of the Fetch Cycle and can
    be mapped to
    the pseudocode: WHILE NOT END OF TABLE and END WHILE.
    Graphically, frames are stacked one atop the other. This may not
    be
    immediately apparent. It is difficult to distinguish which frame
    is beneath
    another. A quick way to see the three-dimensional layering is to
    change the
    color of the frames. Make each frame a different color. This
    will create a
    three-dimensional effect as frames above will partially obscure
    those beneath
    it. You will also notice the layering structure when using the
    object
    navigator in Reports V2.5
    NON-REPEATING FRAMES
    Non-repeating frames are not record-related. They print as often
    as the
    object in which they are enclosed, or to which they are attached
    by an anchor.
    They do not have a print direction.
    REPEATING FRAMES
    Repeating frames are place holders for records. Repeating frames
    print once
    for each record of a group and control record-level formatting.
    Reports will
    generate one repeating frame for each group when you create a
    default layout.
    Reports will place containers of columns inside of the frames.
    Each repeating
    frame retrieves only one row in its fetch cycle for any one
    repetition. Until
    it is constrained by another frame, it will repeat itself until
    the while loop
    condition can no longer be satisfied.
    VERTICAL AND HORIZONTAL SIZING
    The Vertical Sizing of a repeating frame will default to FIXED if
    all the
    objects in the repeating frame are fixed. If the repeating frame
    encloses an
    object (e.g. field, frame) that grows, then the vertical sizing
    defaults to
    VARIABLE or EXPAND.
    FIXED
    If the Vertical Size of the frame is FIXED then the object's
    height is the
    same on each logical page, regardless of the size of the objects
    or data
    within it. Truncation of data may occur. The height of the
    object in the
    layout editor is the actual height of the object at runtime. No
    special
    symbol is indicated on the frame in the layout editor.
    VARIABLE
    If the frame's Vertical Sizing Attribute is VARIABLE and there is
    nothing
    below it, it collapses. For example, if it normally is four lines
    long and
    only one row is returned, then it will not print three blank
    lines but will
    actually collapse the output to one line. If you drag the
    position of the
    fields downward, the space above will not collapse because of the
    IMPLICIT
    ANCHOR. The object will expand or contract vertically to
    accommodate the
    objects or data within it. The height shown in the layout editor
    has no
    effect on the object's height at runtime. The vertical sizing
    attribute
    functions as if you used a combination of contract and expand. A
    diamond
    symbol is indicated on the frame in the layout editor.
    EXPAND
    If the frame's Vertical Sizing Attribute is set to EXPAND, it
    will begin at a
    minimum size defined by the frame, and will expand as necessary
    to accommodate
    more data or lines that exceed the length of the column. An
    equal sign symbol
    is indicated on the frame in the layout editor.
    CONTRACT
    If the frame's Vertical Sizing Attribute is set to CONTRACT, the
    vertical size
    of the object decreases if the formatted objects or data within
    it are short
    enough, but it cannot increase to accommodate larger data.
    Truncation may
    occur. A circle is indicated on the frame in the layout editor.
    FREQUENCY ERRORS
    You may receive frequency errors when a repeating frame is moved
    or deleted,
    thus changing the layering of the frames. Often, users may
    attempt to correct
    this error by adding the deleted frame back, but this does not
    fix the
    problem. The existence of the frame is not enough, even it is
    does not
    overlap other objects in the layout. The frame must also be in
    the right
    position within the hierarchy. In addition to recreating the
    deleted frame,
    you must push the new frame to the right layer using the ARRANGE
    option on the
    Layout menu.
    If you move an object outside its native frame, then you must
    enclose it
    within a repeating frame to group it within the same loop.
    Oracle Worldwide Customer
    Support
    null

  • REP-1213

    Good Morning Everyone,
    We have to put a field and we create a field.
    We assign the value by:
    Property Inspector
    Field
    Source
    Select the Drop down menu
    We have a following Report Builder sign:
    REP-1213: Field'F_1' references column 'Column' at a frequency below its group.
    If you have experiences, please share with us.
    Thanks in advance,
    S!G

    You can see our challenges
    http://apexny.blogspot.com/
    Thank user8674910,
    We did not want to remove the column and set the source of the repeating frame.
    Any option?
    We created Frame and add a Field to assign the column.
    We tried Repeating Frame, too. We have same REP-1213.
    In dataModel:
    We created PlaceHolder Column CP_1
    Drag and Drop the Colum
    We still have the REP-1213 error.
    Fortunately, we founded differnt approch in today. Happy St. Partick's Day!
    If you have a chance, please share with us.
    Thanks,
    Edited by: Sea!Gull on Mar 11, 2011 12:51 PM
    Edited by: Sea!Gull on Mar 17, 2011 8:01 AM

  • REP-1213:  Field F_1 references column EMPNO at a frequency below its group

    Hii guys
    My goal is to display my desired database column where ever i want to on the report layout.For this Purpose
    I ran the following query
    1.SELECT * FROM EMP WHERE EMPNO='7369' in the Data Model.
    2.I then created a field in layout view and gave field source as EMPNO
    3.On Report Run following error was encountered.
    REP-1213: Field F_1 references column EMPNO at a frequency below its group
    Kindly help me in fixing this problem
    Regards
    Fahad Hameed

    dsegard
    Thanks for the tip.I fixed that and now i feel i've some control over my layout.
    How can i apply an image as a water mark throughout my report ??
    Regards
    Fahad Hameed

  • Rep : 1213 Frequency below  group error

    Hi,
    How can I solve the error in a 6i reports having error ' Rep : 1213 Frequency below group error'.
    It occurs when I am putting a ' field' in to the header part of the report. and the source setting as
    the CREATION_DATE , ie 'AMMI_PO_REQUISITION_ALL_V.CREATION_DATE.
    And same error showing when putting field at footer side also. source as AMMI_PO_TO_PEOPLE_V.NAME.
    How can I solve this problem?
    The query of the report is giving below:
    SELECT ALL AMMI_PO_REQUISITION_ALL_V.REQUISITION_HEADER_ID,
    AMMI_PO_REQUISITION_ALL_V.REQUISITION_NO, AMMI_PO_REQUISITION_ALL_V.REQUISITION_LINE_ID,
    AMMI_PO_REQUISITION_ALL_V.CREATION_DATE, AMMI_PO_REQUISITION_ALL_V.LINE_NUM,
    AMMI_PO_REQUISITION_ALL_V.ITEM_ID, AMMI_PO_REQUISITION_ALL_V.QUANTITY,
    AMMI_PO_REQUISITION_ALL_V.PREPARER_ID, AMMI_PO_REQUISITION_ALL_V.SUPPLIER,
    AMMI_PO_REQUISITION_ALL_V.ITEM_CODE, AMMI_PO_REQUISITION_ALL_V.ORGANIZATION_ID,
    AMMI_PO_REQUISITION_ALL_V.DESCRIPTION, AMMI_PO_REQUISITION_ALL_V.PURPOSE,
    AMMI_PO_REQUISITION_ALL_V.BALANCE, AMMI_PO_TO_PEOPLE_V.NAME
    FROM AMMI_PO_REQUISITION_ALL_V, AMMI_PO_TO_PEOPLE_V
    WHERE (AMMI_PO_REQUISITION_ALL_V.PREPARER_ID = AMMI_PO_TO_PEOPLE_V.PERSON_ID)
    and AMMI_PO_REQUISITION_ALL_V.REQUISITION_NO=:P_requisition_no
    and AMMI_PO_REQUISITION_ALL_V.ORGANIZATION_ID=(select ORGANIZATION_ID from AMMI_ORGANIZATIONS_V where name=:P_organization)
    with regards NASEER.

    Hi
    Thanks to the reply.
    In Data modeler I put one placeholder column in side the group. and write function
    as given below.
    function CF_1Formula return Char is
    X VARCHAR2(30);
    begin
    select name into x from AMMI_PO_REQUISITION_ALL_V where REQUISITION_NO= :p_requisition_no;--from parameter form
    return(x);
    end;
    but it is showing Error like 'identifier AMMI_PO_REQUISITION_ALL_V must be declared'
    AMMI_PO_REQUISITION_ALL_V is a view used in the report.
    1. Why this error ?
    2. Where exactly shall I put this placeholder column in data modeler? in side the group or out side?
    With thanks
    Naseer

  • REP-1213 Fld 'Fld Name' references col 'Col Name' @ freq below its group

    I have a report with a repeating frame. The report was working fine until I decided to do some more 'tweaking'. I somehow lost the repeating frame. I went ahead and added a new repeating frame and I'm now getting the following error:
    "REP-1213: Field 'F_Customer_name' references column 'Customer Name' at a frequency below its group."
    I read about the error in the help but, I dont know exactly what it means.
    PLEASE HELP!!

    hello,
    if you are going to the layout model you can move elements
    forward and backward. the easiest way ist to select all fields
    in the layout model (if they are behind the repeating frame you
    will not be able to select them by clicking, use the object
    navigator to select them instead)) and use the BRING TO FRONT
    menu item.
    regards,
    the oracle reports team --pw                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Force the Summary Sub totals on same page as the Repeating Group

    Hello folks,
    I have a Group by Left Report where I am showing Patients and the Visits that they have taken for each Department.
    I am then doing a Sub Total of the number of Visits the Patient has taken. I would like to make sure that the sub total shows
    up on the same page as the data in the Repeating Group. I tried using an Anchor but the Report does not like it.
    It gives an Error: REP 1213 - Field references column at a frequency below its group when I anchor from Repeating frame to the sub total footer
    and REP 1814 Report cannot be formatted. Object 'Horizontally' can never fit within 'M_1' when I try to anchor the other way.
    My goal is to show the Sub Totals (Total) on the same page as the Patient and not go to the next page. I have enclosed the single dashed line and the Total (Label and field) in a Frame.
    Output of Report:
    Patient ID     Patient Name              Department              Visit
    ======================================================================
    1001           Mary Poppins              Department 001              3
                                             Department 002              4
                                             Department 003              1
                                             Total                       8
    1002           Peter Pan                 Department 001              2
                                             Department 002              1
                                             Department 003              2
                                             Total                       5
                                             -----------------------------Thanks in advance!

    Pls set the property(page protect of the frame containing both sub total and patient details) to yes.

  • Error: REP-1259

    Hi,
    I am getting error-1259 in 9i report. It says group ------ has no break coloumns. Please help me to solve the problem

    Hello,
    Even I experience the same error and found the following while resolving the error:
    If it is a Formula column then we dont need to specify any break order. The break order in this case can still be None.
    In my case, the source formula column of the field was not in the desired group. Hence after moving the source formula column into the correct group, the error got resolved.
    Thus sometimes, we can get REP-1259 instead of REP-1213.
    This can occur especially when we are trying to modify an existing report query and as a result, the column grouping may change which then results in these errors.
    Regards,
    K. Sheetal

  • Reg: Implementing a formula in Matrix Reports

    Hi Everyone,
    i have a simple scenario, i have a matrix report with ROWS => EMPNO, COLS => DEPTNO, CELLS => SAL
    Using Matrix report wizard i am able to do this very easily... now i implemented summaries like {AVG,MIN,MAX,SUM } DEPTNO wise using default summary options provided.
    Now i want sum of squares of salaries as one of the summary along with {AVG,MIN,MAX,SUM}
    What is the method to access the cell information in order to use it in formula column.
    Regards,
    Sreekanth

    Hi,
    There are three salaries in a column per deptno, suppose for deptno 10 there are three matching values {10,20,30} now i want them to be (10 square + 20 square + 30 square) in a Formula column CF_1 and then return it into a field which would be placed along with summaries like AVG,MIN,MAX.
    To do the above my formula column code would simple be return(:sal * :sal) in the same group which contains 'sal' but i dont know how many would i get at runtime to sum them up and i tried without summing by giving just return(:sal*:sal) and connected it to a field along with summaries AVG,MIN,MAX and i am getting error:
    "REP-1213: Field 'F_1' references column 'CF_1' at a frequency below its group"
    Hope i am clear.
    Thnaks and Regards,
    Sreekanth.J.U.P

  • Help with Upgrade report in FI

    Hey All Gurus,
    Im in a thick soup here. I am trying to do something like this -
    if you see the selection screen i have rep and super rep, when a user enters a rep value --- it should use the same value to pull all open items for the super rep as well, since they are essentially the same. please help! this one needs to be done fast. i am pasting the code so that it will be easier ...
    thanks a million!
    *& Report  ZFDOFW04_NEW
    REPORT ZFDOFW04_NEW MESSAGE-ID FR
                         LINE-SIZE 132
                         LINE-COUNT 60.
    *==================================================================
    Program: ZFDOFW03 -      Aged Trial Balance Report
             This produces an Accounts Receivable Past Due Aging Report
             in a more simplified/condensed format than the
             SAP supplied aging report program - RFDOPR10.
             This program is a modified copy of RFDOFW00, - a SAP
             Future-Due Report.
             This was a 'rush' job - program probably should be
             rewritten someday not using logical databases as that
             maybe why this runs so slowly!
    Original:  Feb 1997.
    MAINTENANCE HISTORY:
    NES071797   Copied from ZFDOFW03.  Adding parameter for saeles rep.
    JDEDERER - changed header text so it is differnet from ZFDORW03. 9/23
    *TEXT SYMBOLS :
    001 Open items per
    002 O p e n
    003 D u e  o n
    004    cc   ba     in total
    005  until
    006 Days until
    007 Days over
    008 Days
    009 over
    011 valid until........
    012 Insurance limit.....
    016 F u t u r e
    017 + days
    018 D u e
    020 Last dunn.notice...
    021 Dunning level....
    030   S U M M A R Y  S H E E T
    031  =====================
    050 Name           Page
    051 Burton Snowboard
    SELECTION TEXTS:
    SUMMEN   Output totals only
    TAGE1    Due date I until
    TAGE2    Due date II until
    TAGE3    Due date III until
    TAGE4    Due date IV until
    TABLES: T001, KNA1, KNB1, KNB5, BSID, BSEGA, RFPDO1, KNVP,
             T014,                     "credit control areas              JAM
             KNVK,                     "cust master - contact partner     JAM
             T014T,  "Credit control areas names
             BKPF,   "TONY ISSUE 4743
             TVKO,   "TONY ISSUE 4743
             KNKK.                     "cust master - credit mgmt         JAM
    TYPES: BEGIN OF TOT_TYPE,                                  "DEVK939546
              BUKRS LIKE LFB1-BUKRS,                            "DEVK939546
              GSBER LIKE BSIK-GSBER,                            "DEVK939546
              KKBER LIKE BSID-KKBER,
              RAST1 TYPE P,                                     "DEVK939546
              RAST2 TYPE P,                                     "DEVK939546
              RAST3 TYPE P,                                     "DEVK939546
              RAST4 TYPE P,                                     "DEVK939546
              RAST5 TYPE P,                                     "DEVK939546
              RAST6 TYPE P,                                     "DEVK939546
              RAST7 TYPE P,                                     "DEVK939546
            END OF TOT_TYPE,                                    "DEVK939546
            TOT_TAB TYPE TOT_TYPE OCCURS 0.                     "DEVK939546
    CONSTANTS:
             C_FALSE    TYPE I VALUE 0,                                  "JAM
             C_TRUE     TYPE I VALUE 1.
    DATA: BEGIN OF GTAB OCCURS 1000,
              SUPER(10) TYPE C,                                         "TONYC
              REP(10) TYPE C,                                           "TONYC
              FILKD(10),        "tonyc show buying groups
              LAND1 LIKE KNA1-LAND1,
              GSBER LIKE BSIK-GSBER,
              REGIO LIKE KNA1-REGIO,
              NAME1 LIKE KNA1-NAME1,
              NAME2 LIKE KNA1-NAME2,
              ORT01  LIKE KNA1-ORT01,
              TELF1      LIKE KNVK-TELF1,       "telephone number         JAM
              CONT_NAME1 LIKE KNVK-NAME1,       "contact name             JAM
              NAMEV      LIKE KNVK-NAMEV,       "contact name             JAM
              KUNNR LIKE KNA1-KUNNR,                                   "TONYC
              BUKRS LIKE LFB1-BUKRS,                                   "TONYC
              KKBER LIKE BSID-KKBER,     "tonyc issue #2500
              ZTERM LIKE KNB1-ZTERM,     "tonyc issue #2500
              KLIMK_TXT(22)   TYPE C,           "credit limit             JAM
              WAERS      LIKE T014-WAERS,       "currency                 JAM
              SORT_GSB,                                               "TONYC
              RAST1 TYPE P,
              RAST2 TYPE P,
              RAST3 TYPE P,
              RAST4 TYPE P,
              RAST5 TYPE P,
              RAST6 TYPE P,
              RAST7 TYPE P,
              T_IND,
           END OF GTAB.
    DATA HOLD_NAME(40).
    DATA  HOLD_BUKRS LIKE T001-BUKRS.                                 "tonyc
    DATA  GOOD_SUPER_REP.                                             "tonyc
    DATA: HOLD_REP LIKE KNA1-KUNNR,                                   "tonyc
           SUPER_NAME LIKE KNA1-NAME1,                                 "tonyc
           REP_NAME LIKE KNA1-NAME1.                                   "tonyc
    DATA  NAME_LENGTH(2) TYPE C.                                      "tonyc
    DATA  BACKSLASH(3) VALUE ' / '.                                   "tonyc
    DATA  REPS_INFO(70) TYPE C.                                       "tonyc
    DATA  REPORT_TYPE(12) TYPE C.
    DATA:   C_CREDIT_ABTNR LIKE KNVK-ABTNR.    "dept 003 = credit
    DATA  Z_HOLD_LIMIT(22) TYPE N.  "tonyc issue#2216
    DATA  Z_DESCRIPTION(18).   "tonyc issue#2216
    DATA  WRITE_TOTAL.
    DATA  HOLD_KLIMK LIKE KNKK-KLIMK.
    DATA  HOLD_KLIMK2(22) TYPE C.
    DATA  HOLD-CTLPC LIKE KNKK-CTLPC.
    DATA  HOLD-CTLPC-TEXT LIKE T691T-RTEXT.
    DATA  HOLD_ZTERM LIKE KNVV-ZTERM.
    DATA  TOTAL_RAST7 TYPE P.
    DATA  TOTAL_RAST2 TYPE P.
    DATA  TOTAL_RAST3 TYPE P.
    DATA  TOTAL_RAST4 TYPE P.
    DATA  TOTAL_RAST5 TYPE P.
    DATA  TOTAL_RAST6 TYPE P.
    DATA  TOTAL_RAST1 TYPE P.
    DATA  HOLD_BUKRS2 LIKE T001-BUKRS.
    DATA  HOLD_KKBER LIKE BSID-KKBER.
    DATA  HOLD_KKBER_DESC LIKE T014T-KKBTX.
    DATA  HOLD_KKBER_DESC2 LIKE T014T-KKBTX.
    DATA  HOLD_KUNNR2 LIKE KNA1-KUNNR.
    DATA  L_FIRST_DAY_OF_FISCAL LIKE SY-DATUM. "tonyc issue #3047
    DATA: STAB TYPE TOT_TAB WITH HEADER LINE,                  "DEVK939546
           RTOT TYPE TOT_TAB WITH HEADER LINE,                  "DEVK939546
           STOT TYPE TOT_TAB WITH HEADER LINE,                  "DEVK939546
           OP,
           MAXMANDT LIKE DD_STIDA,
           MAXMANST TYPE P,
        SUMKLIMB TYPE P,
           SUMVLIBB TYPE P,
           VERZUG TYPE P,
           OBAD TYPE P,
           BLOCK_CNT TYPE P,
           INTENS,
           ONEBYTE(1) TYPE C,
           TAGE1A LIKE RFPDO1-ALLGFAEL,
           TAGE2A LIKE RFPDO1-ALLGFAEL,
           TAGE3A LIKE RFPDO1-ALLGFAEL,
            HOLD_KUNNR  LIKE KNA1-KUNNR,                          "tonyc
            HOLD_SUPER  LIKE KNA1-KUNNR,                          "tonyc
            HOLD_REP2  LIKE KNA1-KUNNR,                          "tonyc
            SUPER_REP   LIKE KNA1-KUNNR,                          "tonyc
           TEMP_TELF1      LIKE KNA1-TELF1,                              "JAM
           IT_T014         LIKE T014 OCCURS 0 WITH HEADER LINE,          "JAM
           G_KLIMK_TXT     LIKE GTAB-KLIMK_TXT,                          "JAM
           G_WAERS         LIKE GTAB-WAERS,                              "JAM
           G_CONT_NAME(50) TYPE C.                                       "JA
    DATA  FILL_REP_INFO.
       BC     SUNILP      05/14/2007
    DATA: BEGIN OF ITAB_VBRP OCCURS 0.
             INCLUDE STRUCTURE VBRP.
    DATA:  END OF ITAB_VBRP.
    DATA: T_PERC TYPE F,
           SUM_NETWR LIKE VBRP-NETWR.
    *DATA: GTAB_LINES LIKE GTAB OCCURS 0 WITH HEADER LINE.
    DATA: BEGIN OF GTAB_LINES OCCURS 0.
             INCLUDE STRUCTURE GTAB.
    DATA:  IND(1),
            OBAD TYPE P.
    DATA:  END OF GTAB_LINES.
    DATA: BEGIN OF ITAB_VBRP1 OCCURS 0,
           VBELN LIKE VBRP-VBELN,
           NETWR LIKE VBRP-NETWR,
           ZZMREP LIKE VBRP-ZZMREP,       "Super Rep
           ZZLREP LIKE VBRP-ZZLREP,       "Rep
           PERC TYPE F,
           END OF ITAB_VBRP1.
       EC     SUNILP      05/14/2007
    BEGIN_OF_BLOCK 2.
    PARAMETERS: REGIO  LIKE KNA1-REGIO.
    PARAMETERS: CONSOL AS CHECKBOX.                      "TONYC
    PARAMETERS: P_KKBER AS CHECKBOX,                      "TONYC
                 P_CONV AS CHECKBOX.  "tonyc issue #3047
    PARAMETERS: SUMMEN LIKE RFPDO1-ALLGSUMM,
                 TAGE1 LIKE RFPDO1-ALLGFAEL DEFAULT '30',
                 TAGE2 LIKE RFPDO1-ALLGFAEL DEFAULT '60',
                 TAGE3 LIKE RFPDO1-ALLGFAEL DEFAULT '90',
                 TAGE4 LIKE RFPDO1-ALLGFAEL DEFAULT '120'.
    END_OF_BLOCK 2.
    BEGIN_OF_BLOCK 3.
    SELECT-OPTIONS:   P_SUPREP FOR KNVP-KUNNR,   "Super REP      "DEVK939546
                       P_REP FOR KNVP-KUNNR,   "SALES REP         "DEVK939546
                       P_VKORG FOR TVKO-VKORG,  "TONYC ISSUE 4743
                       P_LOTKZ FOR BKPF-LOTKZ.  "TONYC ISSUE 4743
    END_OF_BLOCK 3.
    INITIALIZATION.                                                     "JAM
       PERFORM LOAD_T014.                                                "JAM
         refresh dd_augdt.
         clear dd_augdt.
         dd_augdt-option = 'EQ'.
         dd_augdt-sign   = 'I'.
         dd_augdt-low    = ' '.
        append dd_augdt.
    AT SELECTION-SCREEN.
       IF CONSOL = 'X'.
         IF NOT P_SUPREP[] IS INITIAL.                          "DEVK939546
           MESSAGE E999 WITH 'Consolidated report not allowed w/ Super Rep'.
         ENDIF.
       ENDIF.
    CHECK IF THE REP INFO IS ADDED OR NOT - VS
       IF NOT P_SUPREP IS INITIAL OR"TONY ISSUE 4743
          NOT P_REP IS INITIAL."TONY ISSUE 4743
         FILL_REP_INFO = 'X'."TONY ISSUE 4743
       ENDIF."TONY ISSUE 4743
    START-OF-SELECTION.
    get_frame_title 2.
    add function module to track usage   JD  10/13/98 *****
       CALL FUNCTION 'Z_RUN_LOG'
         EXCEPTIONS
           OTHERS = 1.
    *IF NOT P_SUPREP IS INITIAL AND NOT P_REP IS INITIAL.
       P_SUPREP = ' '.
    *ENDIF.
    GET KNA1 FIELDS LAND1 REGIO KUNNR NAME1 NAME2 ORT01 TELF1.          "JAM
    new-page.
    skip.
       TEMP_TELF1 = KNA1-TELF1.
       MAXMANDT = '19000101'.
       MAXMANST = 0.
       SUMVLIBB = 0.
       PERFORM GET_CUST_CONTACT.                                         "JAM
    Check sales rep-                           NES071797
    Get any valid record and exit.
    IF NOT p_suprep[] IS INITIAL. "DEVK939546  "TONY ISSUE 4743 start
       good_super_rep = ' '.
       SELECT kunn2 INTO super_rep FROM knvp UP TO 1 ROWS
         WHERE
           kunnr = kna1-kunnr AND
           parvw = 'ZS' AND
           kunn2 IN p_suprep.
         EXIT.
       ENDSELECT.
       IF sy-subrc = 0.
         good_super_rep = 'X'.
         gtab-super = super_rep.
         super_rep = ' '.
       ENDIF.
       CHECK good_super_rep = 'X'.
       SELECT kunn2 INTO gtab-rep FROM knvp UP TO 1 ROWS
       WHERE
         kunnr = kna1-kunnr AND
         parvw = 'ZR' AND
         kunn2 IN p_rep.
         EXIT.
       ENDSELECT.
       CHECK sy-subrc = 0.
    ELSEIF NOT p_rep[] IS INITIAL.  "DEVK939546
       SELECT kunn2 INTO gtab-rep FROM knvp UP TO 1 ROWS
         WHERE
           kunnr = kna1-kunnr AND
           parvw = 'ZR' AND
           kunn2 IN p_rep.
         EXIT.
       ENDSELECT.
       CHECK sy-subrc = 0.
    ENDIF.                      "TONY ISSUE 4743 end
    GET KNB1 FIELDS BUKRS VLIBB ZTERM.  "tonyc #2500
       GTAB-BUKRS = KNB1-BUKRS.
    GTAB-ZTERM = KNB1-ZTERM.
       SUMVLIBB = SUMVLIBB + KNB1-VLIBB.
    GET KNB5.
       IF KNB5-MADAT > MAXMANDT.
         MAXMANDT = KNB5-MADAT.
       ENDIF.
       IF KNB5-MAHNS > MAXMANST.
         MAXMANST = KNB5-MAHNS.
       ENDIF.
    SUMKLIMB = SUMKLIMB + KLIMB.
    GET BSID.
       CHECK BSID-BSTAT = SPACE.
    field was intended for Business Area, changed to use Currency
       GTAB-GSBER = BSID-WAERS.
       IF P_KKBER = 'X'.                 "TONYC ISSUE #2500
         IF BSID-KKBER = ' '.
           GTAB-KKBER = BSID-BUKRS.
         ELSE.
           GTAB-KKBER       = BSID-KKBER.  "TONYC ISSUE #2500
         ENDIF.
       ENDIF.                            "TONYC ISSUE #2500
       SELECT SINGLE * FROM BKPF  "TONY ISSUE 4743
          WHERE BUKRS =  BSID-BUKRS "TONY ISSUE 4743
            AND BELNR = BSID-BELNR "TONY ISSUE 4743
            AND GJAHR = BSID-GJAHR. "TONY ISSUE 4743
      BC      SUNILP      05/14/2007
       IF BKPF-XREF2_HD IS NOT INITIAL.
         CHECK BKPF-XREF2_HD IN P_SUPREP. "TONY ISSUE 4743
       ELSE.
         IF P_REP[] IS INITIAL.
           REFRESH: ITAB_VBRP, ITAB_VBRP1.
           IF NOT BKPF-XBLNR IS INITIAL.
             SELECT * FROM VBRP INTO ITAB_VBRP WHERE VBELN = BKPF-XBLNR.
               APPEND ITAB_VBRP. CLEAR ITAB_VBRP.
             ENDSELECT.
            CHECK ITAB_VBRP[] IS NOT INITIAL.
             CLEAR: SUM_NETWR.
             LOOP AT ITAB_VBRP.
               CHECK ITAB_VBRP-ZZMREP IN P_SUPREP.
               CHECK ITAB_VBRP-ZZLREP IN P_REP.
               MOVE-CORRESPONDING ITAB_VBRP TO ITAB_VBRP1.
               COLLECT: ITAB_VBRP1.
               SUM_NETWR = SUM_NETWR + ITAB_VBRP-NETWR.
               CLEAR ITAB_VBRP.
             ENDLOOP.
            CHECK ITAB_VBRP1[] IS NOT INITIAL.
             LOOP AT ITAB_VBRP1.
               CLEAR: T_PERC.
               T_PERC = ( ITAB_VBRP1-NETWR / SUM_NETWR ).
               ITAB_VBRP1-PERC = T_PERC.
               MODIFY ITAB_VBRP1 INDEX SY-TABIX TRANSPORTING PERC.
             ENDLOOP.
           ENDIF.
         ENDIF.
       ENDIF.
      EC      SUNILP      05/14/2007
       IF FILL_REP_INFO = 'X'.
         GTAB-SUPER = BKPF-XREF2_HD. "TONY ISSUE 4743   "MOVE THE CONTENTS OF XREF2_HD TO GTAB INTERNAL TABLE - VS
       ENDIF.
      BC      SUNILP      05/14/2007
       IF BKPF-XREF1_HD IS NOT INITIAL.
         CHECK BKPF-XREF1_HD IN P_REP. "TONY ISSUE 4743  " ELSE MOVE THE CONTENTS OF - VS
       ELSE.
         REFRESH: ITAB_VBRP, ITAB_VBRP1.
         IF NOT BKPF-XBLNR IS INITIAL.
           SELECT * FROM VBRP INTO ITAB_VBRP WHERE VBELN = BKPF-XBLNR.
             APPEND ITAB_VBRP. CLEAR ITAB_VBRP.
           ENDSELECT.
            CHECK ITAB_VBRP[] IS NOT INITIAL.
           CLEAR: SUM_NETWR.
           LOOP AT ITAB_VBRP.
             CHECK ITAB_VBRP-ZZMREP IN P_SUPREP.
             CHECK ITAB_VBRP-ZZLREP IN P_REP.
             MOVE-CORRESPONDING ITAB_VBRP TO ITAB_VBRP1.
             COLLECT: ITAB_VBRP1.
             SUM_NETWR = SUM_NETWR + ITAB_VBRP-NETWR.
             CLEAR ITAB_VBRP.
           ENDLOOP.
            CHECK ITAB_VBRP1[] IS NOT INITIAL.
           LOOP AT ITAB_VBRP1.
             CLEAR: T_PERC.
             T_PERC = ( ITAB_VBRP1-NETWR / SUM_NETWR ).
             ITAB_VBRP1-PERC = T_PERC.
             MODIFY ITAB_VBRP1 INDEX SY-TABIX TRANSPORTING PERC.
           ENDLOOP.
         ENDIF.
       ENDIF.
      EC      SUNILP      05/14/2007
       IF FILL_REP_INFO = 'X'.
         GTAB-REP = BKPF-XREF1_HD. "TONY ISSUE 4743
       ENDIF.
       CHECK BKPF-LOTKZ    IN P_LOTKZ. "TONY ISSUE 4743
       CHECK BKPF-BRNCH    IN P_VKORG. "TONY ISSUE 4743
       SELECT SINGLE FILKD INTO GTAB-FILKD FROM BSEG
          WHERE BUKRS =  BSID-BUKRS
            AND BELNR = BSID-BELNR
            AND GJAHR = BSID-GJAHR
            AND BUZEI = BSID-BUZEI.
    gtab-gsber = bsid-gsber.
    get rep info for each bsid record
    IF NOT P_SUPREP IS INITIAL.                                  "tonyc
        SELECT KUNNR FROM VBPA INTO HOLD_REP UP TO 1 ROWS         "tonyc
              WHERE VBELN = BSID-VBELN                            "tonyc
              AND PARVW = 'ZR'.                                   "tonyc
        ENDSELECT.                                                "tonyc
        IF NOT P_REP IS INITIAL.                                  "tonyc
          CHECK HOLD_REP = P_REP.                                 "tonyc
        ENDIF.                                                    "tonyc
        GTAB-REP = HOLD_REP.                                      "tonyc
        HOLD_REP = ' '.                                           "tonyc
    ENDIF.                                                       "tonyc
       PERFORM GET_KNKK_INFO.                                            "JAM
       GTAB-KLIMK_TXT = G_KLIMK_TXT.
       GTAB-WAERS     = G_WAERS.
       GTAB-LAND1 = KNA1-LAND1.
       GTAB-REGIO = KNA1-REGIO.
       GTAB-KUNNR = KNA1-KUNNR.
       GTAB-NAME1 = KNA1-NAME1.
       GTAB-NAME2 = KNA1-NAME2.
       GTAB-ORT01 = KNA1-ORT01.
    *if there is no phone number for the contact, pull the phone
    *number from the sold-to
       IF KNVK-TELF1 = ' '.
         GTAB-TELF1      = TEMP_TELF1.
       ELSE.
         GTAB-TELF1      = KNVK-TELF1.                                 "JAM
       ENDIF.
       GTAB-CONT_NAME1 = KNVK-NAME1.
       GTAB-NAMEV      = KNVK-NAMEV.
    verzug = bsega-netdt - dd_stida.
       VERZUG = DD_STIDA - BSEGA-NETDT.     "days past due calculation
       OP = 'X'.
       GTAB-RAST2 = GTAB-RAST3 = GTAB-RAST4 = 0.
       GTAB-RAST5 = GTAB-RAST6 = OBAD = GTAB-RAST7 = 0.
       IF VERZUG LE 0.                      "future due
         GTAB-RAST1 = BSEGA-WRSHB.
       ELSE.
         IF VERZUG LE TAGE1.                "past due 1 to tage1 days
           GTAB-RAST1 = BSEGA-WRSHB.
           GTAB-RAST2 = BSEGA-WRSHB.
           OBAD       = BSEGA-WRSHB.
         ELSE.
           IF VERZUG LE TAGE2.              "past due tage1 to tage2 days
             GTAB-RAST1 = BSEGA-WRSHB.
             GTAB-RAST3 = BSEGA-WRSHB.
             OBAD       = BSEGA-WRSHB.
           ELSE.
             IF VERZUG LE TAGE3.            "past due tage2 to tage3 days
               GTAB-RAST1 = BSEGA-WRSHB.
               GTAB-RAST4 = BSEGA-WRSHB.
               OBAD       = BSEGA-WRSHB.
             ELSE.
               IF VERZUG LE TAGE4.          "past due tage3 to tage4 days
                 GTAB-RAST1 = BSEGA-WRSHB.
                 GTAB-RAST5 = BSEGA-WRSHB.
                 OBAD       = BSEGA-WRSHB.
               ELSE.
                 IF VERZUG GT TAGE4.        "past due > tage4 days
                   GTAB-RAST1 = BSEGA-WRSHB.
                   GTAB-RAST6 = BSEGA-WRSHB.
                   OBAD       = BSEGA-WRSHB.
                 ENDIF.
               ENDIF.
             ENDIF.
           ENDIF.
         ENDIF.
       ENDIF.
       GTAB-RAST7 = GTAB-RAST1 - OBAD.
    stab = gtab.
       MOVE-CORRESPONDING GTAB TO STAB.
      BC     SUNILP       05/15/2007
       IF ITAB_VBRP1[] IS NOT INITIAL.
         GTAB-T_IND = 'X'.
         LOOP AT ITAB_VBRP1.
           MOVE-CORRESPONDING GTAB TO GTAB_LINES.
           GTAB_LINES-SORT_GSB =  '1'.
           GTAB_LINES-SUPER = ITAB_VBRP1-ZZMREP.
           GTAB_LINES-REP = ITAB_VBRP1-ZZLREP.
           GTAB_LINES-RAST1 = GTAB_LINES-RAST1 * ITAB_VBRP1-PERC.
           GTAB_LINES-RAST2 = GTAB_LINES-RAST2 * ITAB_VBRP1-PERC.
           GTAB_LINES-RAST3 = GTAB_LINES-RAST3 * ITAB_VBRP1-PERC.
           GTAB_LINES-RAST4 = GTAB_LINES-RAST4 * ITAB_VBRP1-PERC.
           GTAB_LINES-RAST5 = GTAB_LINES-RAST5 * ITAB_VBRP1-PERC.
           GTAB_LINES-RAST6 = GTAB_LINES-RAST6 * ITAB_VBRP1-PERC.
           GTAB_LINES-RAST7 = GTAB_LINES-RAST7 * ITAB_VBRP1-PERC.
      GTAB_LINES-OBAD  = GTAB_LINES-OBAD  * ITAB_VBRP1-PERC.
           COLLECT: GTAB_LINES.
         ENDLOOP.
       ELSE.
         MOVE-CORRESPONDING GTAB TO GTAB_LINES.
         GTAB_LINES-T_IND =  'X'.
         GTAB_LINES-SORT_GSB =  '1'.
         IF GTAB_LINES-SUPER IN P_SUPREP OR GTAB_LINES-REP IN P_REP.
           COLLECT: GTAB_LINES.
         ENDIF.
       ENDIF.
      EC     SUNILP       05/15/2007
    gtab-sort_gsb = stab-sort_gsb = '0'.
    collect: gtab, stab.
    gtab-gsber = stab-gsber = '****'.
       GTAB-SORT_GSB =  '1'.
       IF REGIO = SPACE OR REGIO = GTAB-REGIO.
         IF GTAB_LINES-SUPER IN P_SUPREP OR GTAB_LINES-REP IN P_REP.
           COLLECT: GTAB, STAB.
         ENDIF.
       ENDIF.
    END-OF-SELECTION.
       TAGE1A = TAGE1 + 1.
       TAGE2A = TAGE2 + 1.
       TAGE3A = TAGE3 + 1.
       IF  SUMMEN = ' '.
       sort gtab by bukrs land1 regio kunnr gsber sort_gsb.
      sort gtab by bukrs land1 regio name1 kunnr gsber sort_gsb.      "JAM
         IF CONSOL = 'X'.
           SORT GTAB BY LAND1 REGIO NAME1 KUNNR BUKRS KKBER GSBER SORT_GSB.
           "TONYC
           REPORT_TYPE = 'consolidated'.
         ELSEIF NOT P_SUPREP[] IS INITIAL.                      "DEVK939546
           SORT GTAB
             BY SUPER REP NAME1 BUKRS KKBER LAND1 REGIO NAME1 GSBER SORT_GSB.
      BC   SUNILP   05/15/2007
           SORT GTAB_LINES
             BY SUPER REP NAME1 BUKRS KKBER LAND1 REGIO NAME1 GSBER SORT_GSB.
      EC   SUNILP   05/15/2007
           REPORT_TYPE = 'super rep'.
           CLEAR STAB.   "tonyc 03/06/2004
           REFRESH STAB. "tonyc 03/06/2004
         ELSEIF NOT P_REP[] IS INITIAL.                         "DEVK939546
           SORT GTAB                                            "DEVK939546
             BY REP NAME1 BUKRS KKBER LAND1 REGIO NAME1 GSBER SORT_GSB.
                                                                "DEVK939546
      BC   SUNILP   05/15/2007
           SORT GTAB_LINES
             BY REP NAME1 BUKRS KKBER LAND1 REGIO NAME1 GSBER SORT_GSB.
      EC   SUNILP   05/15/2007
           REPORT_TYPE = 'rep'.                                 "DEVK939546
           CLEAR STAB.   "tonyc 03/06/2004
           REFRESH STAB. "tonyc 03/06/2004
         ELSE.
           SORT GTAB BY BUKRS KKBER LAND1 REGIO NAME1 KUNNR GSBER SORT_GSB.
      BC   SUNILP   05/15/2007
           SORT GTAB_LINES BY BUKRS KKBER LAND1 REGIO NAME1 KUNNR GSBER SORT_GSB.
      EC   SUNILP   05/15/2007
           REPORT_TYPE = 'regular'.
         ENDIF.
      BC   SUNILP   05/15/2007
         DELETE ADJACENT DUPLICATES FROM GTAB COMPARING BUKRS NAME1.
         LOOP AT GTAB_LINES.
           IF P_REP[] IS INITIAL.
             IF GTAB_LINES-SUPER NOT IN P_SUPREP.
               DELETE GTAB_LINES.
             ENDIF.
           ELSE.
             IF GTAB_LINES-SUPER NOT IN P_SUPREP OR GTAB_LINES-REP NOT IN P_REP.
               DELETE GTAB_LINES.
             ENDIF.
           ENDIF.
         ENDLOOP.
         LOOP AT GTAB.
           READ TABLE GTAB_LINES WITH KEY BUKRS = GTAB-BUKRS
                                          NAME1 = GTAB-NAME1.
           IF SY-SUBRC NE '0'.
             DELETE GTAB.
           ENDIF.
         ENDLOOP.
      EC   SUNILP   05/15/2007
         LOOP AT GTAB.
           MOVE GTAB-BUKRS TO T001-BUKRS. READ TABLE T001.
           RESERVE 5 LINES.
           CASE REPORT_TYPE.
             WHEN 'regular'.
               IF HOLD_BUKRS <> GTAB-BUKRS.
                 IF SY-TABIX > 1.                                   "TONYC
                   NEW-PAGE. SKIP.                                 "TONYC
                 ENDIF.                                             "TONYC
               ENDIF.
               PERFORM WRITE_CUST_INFO.                               "TONYC
               PERFORM WRITE_DETAIL.
             hold_bukrs = gtab-bukrs.                               "tonyc
             WHEN 'consolidated'.
               IF HOLD_KUNNR <> GTAB-KUNNR.                           "TONYC
                 PERFORM WRITE_CUST_INFO.                           "TONYC
               ENDIF.                                                 "TONYC
               HOLD_KUNNR = GTAB-KUNNR.                               "TONYC
               PERFORM WRITE_DETAIL.
             WHEN 'super rep'.
              IF GTAB-T_IND NE 'X'.
       BC     SUNILP     05/22/2007
                READ TABLE GTAB_LINES WITH KEY BUKRS = GTAB-BUKRS
                                               NAME1 = GTAB-NAME1.
       EC     SUNILP     05/22/2007
                IF ( HOLD_SUPER <> GTAB_LINES-SUPER ) OR
                   ( HOLD_REP2 <> GTAB_LINES-REP ).
                  NEW-PAGE.
                  PERFORM GET_AND_WRITE_SUPERINFO.
                ENDIF.
                HOLD_REP2 = GTAB_LINES-REP.
                HOLD_SUPER = GTAB_LINES-SUPER.
                IF HOLD_KUNNR <> GTAB-KUNNR.                           "TONYC
                  WRITE :/.                                           "TONYC
                  ULINE.                                              "TONYC
                  PERFORM WRITE_CUST_INFO.                            "TONYC
                ENDIF.                                                 "TONYC
                HOLD_KUNNR = GTAB-KUNNR.                               "TONYC
                PERFORM WRITE_DETAIL.                                  "TONYC
                AT END OF REP.                                 "DEVK939546
                  SKIP.                                        "DEVK939546
                  RESERVE 7 LINES.                             "DEVK939546
                  FORMAT COLOR COL_TOTAL INTENSIFIED.          "DEVK939546
                  WRITE: / 'Summary for Rep:',                 "DEVK939546
                            GTAB-REP, '/', REP_NAME, 132 ONEBYTE."DEVK939546
                  PERFORM WRITE_TOTS TABLES RTOT.              "DEVK939546
                  REFRESH RTOT.                                "DEVK939546
                ENDAT.                                         "DEVK939546
                AT END OF SUPER.                               "DEVK939546
                  CLEAR STAB.   "tonyc 03/06/2004
                  REFRESH STAB. "tonyc 03/06/2004
                  NEW-PAGE. SKIP.                              "DEVK939546
                  FORMAT COLOR COL_TOTAL INTENSIFIED.          "DEVK939546
                  WRITE: / 'Summary for Super Rep:',           "DEVK939546
                         GTAB-SUPER, '/', SUPER_NAME, 132 ONEBYTE."DEVK939546
                  PERFORM WRITE_TOTS TABLES STOT.              "DEVK939546
                  REFRESH STOT.                                "DEVK939546
                ENDAT.                                         "DEVK939546
              ELSE.
               LOOP AT GTAB_LINES WHERE BUKRS = GTAB-BUKRS
                                    AND NAME1 = GTAB-NAME1.
                 IF ( HOLD_SUPER <> GTAB_LINES-SUPER ) OR
                    ( HOLD_REP2 <> GTAB_LINES-REP ).
                   NEW-PAGE.
                   PERFORM GET_AND_WRITE_SUPERINFO.
                 ENDIF.
                 HOLD_REP2 = GTAB_LINES-REP.
                 HOLD_SUPER = GTAB_LINES-SUPER.
                 IF HOLD_KUNNR <> GTAB_LINES-KUNNR.
                   WRITE :/.
                   ULINE.
                   PERFORM WRITE_CUST_INFO.
                 ENDIF.
                 HOLD_KUNNR = GTAB_LINES-KUNNR.
                 PERFORM WRITE_DETAIL.
                 AT END OF REP.
                   SKIP.
                   RESERVE 7 LINES.
                   FORMAT COLOR COL_TOTAL INTENSIFIED.
                   WRITE: / 'Summary for Rep:',
                             GTAB_LINES-REP, '/', REP_NAME, 132 ONEBYTE.
                   PERFORM WRITE_TOTS TABLES RTOT.
                   REFRESH RTOT.
                 ENDAT.
                 AT END OF SUPER.
                   CLEAR STAB.   "tonyc 03/06/2004
                   REFRESH STAB. "tonyc 03/06/2004
                   NEW-PAGE. SKIP.
                   FORMAT COLOR COL_TOTAL INTENSIFIED.
                   WRITE: / 'Summary for Super Rep:',
                          GTAB_LINES-SUPER, '/', SUPER_NAME, 132 ONEBYTE.
                   PERFORM WRITE_TOTS TABLES STOT.
                   REFRESH STOT.
                 ENDAT.
               ENDLOOP.
              ENDIF.
             WHEN 'rep'.                                        "DEVK939546
               LOOP AT GTAB_LINES WHERE BUKRS = GTAB-BUKRS
                                    AND NAME1 = GTAB-NAME1.
                 IF HOLD_REP2 <> GTAB_LINES-REP.                "DEVK939546
                   NEW-PAGE.                                    "DEVK939546
                   PERFORM GET_AND_WRITE_REPINFO.               "DEVK939546
                 ENDIF.                                         "DEVK939546
                 HOLD_REP2 = GTAB_LINES-REP.                    "DEVK939546
                 IF HOLD_KUNNR <> GTAB_LINES-KUNNR.             "DEVK939546
                   WRITE :/.                                    "DEVK939546
                   ULINE.                                       "DEVK939546
                   PERFORM WRITE_CUST_INFO.                     "DEVK939546
                 ENDIF.                                         "DEVK939546
                 HOLD_KUNNR = GTAB_LINES-KUNNR.                 "DEVK939546
                 PERFORM WRITE_DETAIL.                          "DEVK939546
                 AT END OF REP.                                 "DEVK939546
                   SKIP.                                        "DEVK939546
                   RESERVE 7 LINES.                             "DEVK939546
                   FORMAT COLOR COL_TOTAL INTENSIFIED.          "DEVK939546
                   WRITE: / 'Summary for Rep:',                 "DEVK939546
                             GTAB_LINES-REP, '/', REP_NAME, 132 ONEBYTE."DEVK939546
                   PERFORM WRITE_TOTS TABLES RTOT.              "DEVK939546
                   REFRESH RTOT.                                "DEVK939546
                 ENDAT.                                         "DEVK939546
               ENDLOOP.
           ENDCASE.
         ENDLOOP.
       ENDIF.
       OP = ' '.
       REFRESH GTAB.
       IF NOT REPORT_TYPE = 'super rep'.
         ULINE.
       ENDIF.
       SKIP 1.
       IF  SUMMEN = ' '.  "if 'output totals only' bypass new-page
         NEW-PAGE. SKIP.
       ENDIF.
       WRITE: /25 TEXT-030, 132 ONEBYTE, /25 TEXT-031, 132 ONEBYTE.
       PERFORM WRITE_TOTS TABLES STAB.                          "DEVK939546
    TOP-OF-PAGE.
       INTENS = SPACE.
       FORMAT COLOR COL_HEADING INTENSIFIED ON.
       WRITE: / SY-VLINE, 1 TEXT-001, DD_STIDA, 75 TEXT-051, 132 SY-VLINE.
       ULINE.
       WRITE: / SY-VLINE, 13 SY-VLINE, 30 SY-VLINE,
                    47 SY-VLINE, 58 TEXT-003, 81 SY-VLINE,
              92 TEXT-003, 115 SY-VLINE, 118  TEXT-003, 132 SY-VLINE,
              / SY-VLINE, 02 TEXT-004, 13 SY-VLINE, TEXT-002,
                    30 SY-VLINE, 32 TEXT-018, 47 SY-VLINE,
                  50 '1', 54 TEXT-040, 57 TAGE1, 64 SY-VLINE,   " 65 tage2,
                  67 TAGE1A, 72 TEXT-040, 75 TAGE2,
                81 SY-VLINE, 83 TAGE2A, 89 TEXT-040, 91 TAGE3, 98 SY-VLINE,
               101 TAGE3A, 107 TEXT-040, 110 TAGE4, 115 SY-VLINE,
                                   117 TAGE4, 123  TEXT-017, 132 SY-VLINE.
       ULINE.
       SKIP 1.
       SUMMARY.
       FORMAT COLOR COL_HEADING INTENSIFIED OFF.
          FORM write_tots                                               *
    -->  PTAB                                                          *
    FORM WRITE_TOTS TABLES PTAB TYPE TOT_TAB.                  "DEVK939546
       CLEAR INTENS.                                            "DEVK939546
       FORMAT COLOR COL_HEADING INTENSIFIED OFF.                "DEVK939546
       IF P_CONV = 'X'. "tonyc issue #3047 begin
         WRITE /4 TEXT-101.
         WRITE: /4 TEXT-102,
                50 TEXT-100.
       ENDIF.           "tonyc issue #3047 end
       ULINE.                                                   "DEVK939546
       SORT PTAB BY BUKRS GSBER.                                "DEVK939546
       LOOP AT PTAB.                                            "DEVK939546
         IF SY-TABIX > 1.
           WRITE_TOTAL = 'X'.
         ENDIF.
         MOVE PTAB-BUKRS TO T001-BUKRS. READ TABLE T001.        "DEVK939546
         MOVE PTAB-GSBER TO T001-WAERS.                         "DEVK939546
         IF P_CONV = 'X'. "tonyc issue #3047 begin
           PERFORM CONVERT_VALUES USING STAB-RAST1
                                        STAB-GSBER.
           PERFORM CONVERT_VALUES USING STAB-RAST2
                                        STAB-GSBER.
           PERFORM CONVERT_VALUES USING STAB-RAST3
                                        STAB-GSBER.
           PERFORM CONVERT_VALUES USING STAB-RAST4
                                        STAB-GSBER.
           PERFORM CONVERT_VALUES USING STAB-RAST5
                                        STAB-GSBER.
           PERFORM CONVERT_VALUES USING STAB-RAST6
                                        STAB-GSBER.
           PERFORM CONVERT_VALUES USING STAB-RAST7
                                        STAB-GSBER.
         ENDIF.  "TOnyc issue #3047 end
         MOVE-CORRESPONDING PTAB TO STAB.
         COLLECT STAB.
         IF P_KKBER = 'X'.        "TONYC ISSUE #2500
           CLEAR HOLD_KKBER_DESC2.
           SELECT SINGLE KKBTX INTO HOLD_KKBER_DESC2 FROM T014T
              WHERE KKBER = STAB-KKBER AND
                    SPRAS = 'E'.
           IF SY-SUBRC <> '0'.
             HOLD_KKBER_DESC2 = 'Undetermined'.
           ENDIF.
           FORMAT COLOR OFF.
           WRITE: / SY-VLINE.
           FORMAT COLOR COL_HEADING INTENSIFIED OFF.
           WRITE: 6 STAB-GSBER, HOLD_KKBER_DESC2, SY-VLINE.
           ULINE.
           FORMAT COLOR OFF.
           WRITE: / SY-VLINE.
           FORMAT COLOR COL_HEADING INTENSIFIED OFF.
           IF P_CONV = 'X'. "tonyc issue #3047 begin
             T001-WAERS = 'USD'.
           ENDIF.           "tonyc issue #3047 end
           WRITE: 13 STAB-RAST1 NO-ZERO CURRENCY T001-WAERS, SY-VLINE,
           (14) STAB-RAST7 NO-ZERO CURRENCY T001-WAERS, SY-VLINE,
           (14) STAB-RAST2 NO-ZERO CURRENCY T001-WAERS, SY-VLINE,
           (14) STAB-RAST3 NO-ZERO CURRENCY T001-WAERS, SY-VLINE,
           (14) STAB-RAST4 NO-ZERO CURRENCY T001-WAERS, SY-VLINE,
           (14) STAB-RAST5 NO-ZERO CURRENCY T001-WAERS, SY-VLINE,
           (14) STAB-RAST6 NO-ZERO CURRENCY T001-WAERS, SY-VLINE.
           HOLD_BUKRS2 = STAB-BUKRS.      "TONYC ISSUE #2500
           ULINE.
           FORMAT COLOR OFF.
           TOTAL_RAST1 = STAB-RAST1 + TOTAL_RAST1.
           TOTAL_RAST2 = STAB-RAST2 + TOTAL_RAST2.
           TOTAL_RAST3 = STAB-RAST3 + TOTAL_RAST3.
           TOTAL_RAST4 = STAB-RAST4 + TOTAL_RAST4.
           TOTAL_RAST5 = STAB-RAST5 + TOTAL_RAST5.
           TOTAL_RAST6 = STAB-RAST6 + TOTAL_RAST6.
           TOTAL_RAST7 = STAB-RAST7 + TOTAL_RAST7.
         ELSE.
           FORMAT COLOR COL_NORMAL INTENSIFIED OFF.             "DEVK939546
           IF INTENS = SPACE.                                   "DEVK939546
             FORMAT COLOR COL_NORMAL INTENSIFIED OFF.           "DEVK939546
             INTENS = 'X'.                                      "DEVK939546
           ELSE.                                                "DEVK939546
             FORMAT COLOR COL_NORMAL INTENSIFIED ON.            "DEVK939546
             INTENS = SPACE.                                    "DEVK939546
           ENDIF.                                               "DEVK939546
           WRITE: / SY-VLINE, PTAB-BUKRS, PTAB-GSBER, SY-VLINE, "DEVK939546
            (14) PTAB-RAST1 NO-ZERO CURRENCY T001-WAERS, SY-VLINE,"DEVK939546
            (14) PTAB-RAST7 NO-ZERO CURRENCY T001-WAERS, SY-VLINE,"DEVK939546
            (14) PTAB-RAST2 NO-ZERO CURRENCY T001-WAERS, SY-VLINE,"DEVK939546
            (14) PTAB-RAST3 NO-ZERO CURRENCY T001-WAERS, SY-VLINE,"DEVK939546
            (14) PTAB-RAST4 NO-ZERO CURRENCY T001-WAERS, SY-VLINE,"DEVK939546
            (14) PTAB-RAST5 NO-ZERO CURRENCY T001-WAERS, SY-VLINE,"DEVK939546
            (14) PTAB-RAST6 NO-ZERO CURRENCY T001-WAERS, SY-VLINE."DEVK939546
           TOTAL_RAST1 = STAB-RAST1 + TOTAL_RAST1.
           TOTAL_RAST2 = STAB-RAST2 + TOTAL_RAST2.
           TOTAL_RAST3 = STAB-RAST3 + TOTAL_RAST3.
           TOTAL_RAST4 = STAB-RAST4 + TOTAL_RAST4.
           TOTAL_RAST5 = STAB-RAST5 + TOTAL_RAST5.
           TOTAL_RAST6 = STAB-RAST6 + TOTAL_RAST6.
           TOTAL_RAST7 = STAB-RAST7 + TOTAL_RAST7.
         ENDIF.
       ENDLOOP.                                                 "DEVK939546
       ULINE.                                                   "DEVK939546
       IF P_KKBER = 'X'.        "TONYC ISSUE #2500
         IF P_CONV = 'X'.  "tonyc issue #3047 begin
           FORMAT COLOR OFF.
           FORMAT COLOR COL_HEADING INTENSIFIED OFF.
           WRITE: SY-VLINE,
                6 'TOTAL                                   ', SY-VLINE.
           ULINE.
           FORMAT COLOR OFF.
           WRITE: / SY-VLINE.
           FORMAT COLOR COL_HEADING INTENSIFIED OFF.
           WRITE: 13 TOTAL_RAST1 NO-ZERO CURRENCY T001-WAERS, SY-VLINE,
           (14) TOTAL_RAST7 NO-ZERO CURRENCY T001-WAERS, SY-VLINE,
           (14) TOTAL_RAST2 NO-ZERO CURRENCY T001-WAERS, SY-VLINE,
           (14) TOTAL_RAST3 NO-ZERO CURRENCY T001-WAERS, SY-VLINE,
           (14) TOTAL_RAST4 NO-ZERO CURRENCY T001-WAERS, SY-VLINE,
           (14) TOTAL_RAST5 NO-ZERO CURRENCY T001-WAERS, SY-VLINE,
           (14) TOTAL_RAST6 NO-ZERO CURRENCY T001-WAERS, SY-VLINE.
           ULINE.
         ENDIF. "tonyc issue #3047 end
       ELSE.
         IF P_CONV = 'X'.
           FORMAT COLOR OFF.
           FORMAT COLOR COL_HEADING INTENSIFIED OFF.
           WRITE: SY-VLINE,
                6 'TOTAL                                   ', SY-VLINE.
           ULINE.
           FORMAT COLOR OFF.
           WRITE: / SY-VLINE.
           FORMAT COLOR COL_HEADING INTENSIFIED OFF.
           WRITE: 13 TOTAL_RAST1 NO-ZERO CURRENCY T001-WAERS, SY-VLINE,
           (14) TOTAL_RAST7 NO-ZERO CURRENCY T001-WAERS, SY-VLINE,
           (14) TOTAL_RAST2 NO-ZERO CURRENCY T001-WAERS, SY-VLINE,
           (14) TOTAL_RAST3 NO-ZERO CURRENCY T001-WAERS, SY-VLINE,
           (14) TOTAL_RAST4 NO-ZERO CURRENCY T001-WAERS, SY-VLINE,
           (14) TOTAL_RAST5 NO-ZERO CURRENCY T001-WAERS, SY-VLINE,
           (14) TOTAL_RAST6 NO-ZERO CURRENCY T001-WAERS, SY-VLINE.
           ULINE.
         ENDIF.
       ENDIF.
       SKIP 1.                                                  "DEVK939546
    ENDFORM.                                                   "DEVK939546
    *&      Form  GET_KNKK_INFO
          text
    -->  p1        text
    <--  p2        text
    FORM GET_KNKK_INFO.
       CLEAR: G_WAERS,
              G_KLIMK_TXT,
              KNKK-KLIMK.
    get credit control area (KKBER) for comp code (BUKRS)
       SELECT SINGLE KLIMK
              INTO   KNKK-KLIMK
              FROM   KNKK
              WHERE  KUNNR = KNA1-KUNNR  AND
                     KKBER = T001-KKBER.
       IF SY-SUBRC = 0.
      get currency for cred ctrl area
         CLEAR IT_T014.
         READ TABLE IT_T014 WITH KEY KKBER = T001-KKBER BINARY SEARCH.
         G_WAERS = IT_T014-WAERS.
         WRITE KNKK-KLIMK TO G_KLIMK_TXT CURRENCY G_WAERS.
       ENDIF.
    ENDFORM.                    " GET_KNKK_INFO
    *&      Form  SELECT_KNKK
          text
         -->P_KKBER       Credit Limit Controlling Area

    This is a FI Aging report.

  • Ar aging report, need help urgent please help!

    Hey All Gurus,
    Im in a thick soup here. I am trying to do something like this -
    if you see the selection screen i have rep and super rep, when a user enters a rep value --- it should use the same value to pull all open items for the super rep as well, since they are essentially the same. please help! this one needs to be done fast. i am pasting the code so that it will be easier ...
    thanks a million!
    *& Report ZFDOFW04_NEW
    REPORT ZFDOFW04_NEW MESSAGE-ID FR
    LINE-SIZE 132
    LINE-COUNT 60.
    *==================================================================
    Program: ZFDOFW03 - Aged Trial Balance Report
    This produces an Accounts Receivable Past Due Aging Report
    in a more simplified/condensed format than the
    SAP supplied aging report program - RFDOPR10.
    This program is a modified copy of RFDOFW00, - a SAP
    Future-Due Report.
    This was a 'rush' job - program probably should be
    rewritten someday not using logical databases as that
    maybe why this runs so slowly!
    Original: Feb 1997.
    MAINTENANCE HISTORY:
    NES071797 Copied from ZFDOFW03. Adding parameter for saeles rep.
    JDEDERER - changed header text so it is differnet from ZFDORW03. 9/23
    *TEXT SYMBOLS :
    001 Open items per
    002 O p e n
    003 D u e o n
    004 cc ba in total
    005 until
    006 Days until
    007 Days over
    008 Days
    009 over
    011 valid until........
    012 Insurance limit.....
    016 F u t u r e
    017 + days
    018 D u e
    020 Last dunn.notice...
    021 Dunning level....
    030 S U M M A R Y S H E E T
    031 =====================
    050 Name Page
    051 Burton Snowboard
    SELECTION TEXTS:
    SUMMEN Output totals only
    TAGE1 Due date I until
    TAGE2 Due date II until
    TAGE3 Due date III until
    TAGE4 Due date IV until
    TABLES: T001, KNA1, KNB1, KNB5, BSID, BSEGA, RFPDO1, KNVP,
    T014, "credit control areas JAM
    KNVK, "cust master - contact partner JAM
    T014T, "Credit control areas names
    BKPF, "TONY ISSUE 4743
    TVKO, "TONY ISSUE 4743
    KNKK. "cust master - credit mgmt JAM
    TYPES: BEGIN OF TOT_TYPE, "DEVK939546
    BUKRS LIKE LFB1-BUKRS, "DEVK939546
    GSBER LIKE BSIK-GSBER, "DEVK939546
    KKBER LIKE BSID-KKBER,
    RAST1 TYPE P, "DEVK939546
    RAST2 TYPE P, "DEVK939546
    RAST3 TYPE P, "DEVK939546
    RAST4 TYPE P, "DEVK939546
    RAST5 TYPE P, "DEVK939546
    RAST6 TYPE P, "DEVK939546
    RAST7 TYPE P, "DEVK939546
    END OF TOT_TYPE, "DEVK939546
    TOT_TAB TYPE TOT_TYPE OCCURS 0. "DEVK939546
    CONSTANTS:
    C_FALSE TYPE I VALUE 0, "JAM
    C_TRUE TYPE I VALUE 1.
    DATA: BEGIN OF GTAB OCCURS 1000,
    SUPER(10) TYPE C, "TONYC
    REP(10) TYPE C, "TONYC
    FILKD(10), "tonyc show buying groups
    LAND1 LIKE KNA1-LAND1,
    GSBER LIKE BSIK-GSBER,
    REGIO LIKE KNA1-REGIO,
    NAME1 LIKE KNA1-NAME1,
    NAME2 LIKE KNA1-NAME2,
    ORT01 LIKE KNA1-ORT01,
    TELF1 LIKE KNVK-TELF1, "telephone number JAM
    CONT_NAME1 LIKE KNVK-NAME1, "contact name JAM
    NAMEV LIKE KNVK-NAMEV, "contact name JAM
    KUNNR LIKE KNA1-KUNNR, "TONYC
    BUKRS LIKE LFB1-BUKRS, "TONYC
    KKBER LIKE BSID-KKBER, "tonyc issue #2500
    ZTERM LIKE KNB1-ZTERM, "tonyc issue #2500
    KLIMK_TXT(22) TYPE C, "credit limit JAM
    WAERS LIKE T014-WAERS, "currency JAM
    SORT_GSB, "TONYC
    RAST1 TYPE P,
    RAST2 TYPE P,
    RAST3 TYPE P,
    RAST4 TYPE P,
    RAST5 TYPE P,
    RAST6 TYPE P,
    RAST7 TYPE P,
    T_IND,
    END OF GTAB.
    DATA HOLD_NAME(40).
    DATA HOLD_BUKRS LIKE T001-BUKRS. "tonyc
    DATA GOOD_SUPER_REP. "tonyc
    DATA: HOLD_REP LIKE KNA1-KUNNR, "tonyc
    SUPER_NAME LIKE KNA1-NAME1, "tonyc
    REP_NAME LIKE KNA1-NAME1. "tonyc
    DATA NAME_LENGTH(2) TYPE C. "tonyc
    DATA BACKSLASH(3) VALUE ' / '. "tonyc
    DATA REPS_INFO(70) TYPE C. "tonyc
    DATA REPORT_TYPE(12) TYPE C.
    DATA: C_CREDIT_ABTNR LIKE KNVK-ABTNR. "dept 003 = credit
    DATA Z_HOLD_LIMIT(22) TYPE N. "tonyc issue#2216
    DATA Z_DESCRIPTION(18). "tonyc issue#2216
    DATA WRITE_TOTAL.
    DATA HOLD_KLIMK LIKE KNKK-KLIMK.
    DATA HOLD_KLIMK2(22) TYPE C.
    DATA HOLD-CTLPC LIKE KNKK-CTLPC.
    DATA HOLD-CTLPC-TEXT LIKE T691T-RTEXT.
    DATA HOLD_ZTERM LIKE KNVV-ZTERM.
    DATA TOTAL_RAST7 TYPE P.
    DATA TOTAL_RAST2 TYPE P.
    DATA TOTAL_RAST3 TYPE P.
    DATA TOTAL_RAST4 TYPE P.
    DATA TOTAL_RAST5 TYPE P.
    DATA TOTAL_RAST6 TYPE P.
    DATA TOTAL_RAST1 TYPE P.
    DATA HOLD_BUKRS2 LIKE T001-BUKRS.
    DATA HOLD_KKBER LIKE BSID-KKBER.
    DATA HOLD_KKBER_DESC LIKE T014T-KKBTX.
    DATA HOLD_KKBER_DESC2 LIKE T014T-KKBTX.
    DATA HOLD_KUNNR2 LIKE KNA1-KUNNR.
    DATA L_FIRST_DAY_OF_FISCAL LIKE SY-DATUM. "tonyc issue #3047
    DATA: STAB TYPE TOT_TAB WITH HEADER LINE, "DEVK939546
    RTOT TYPE TOT_TAB WITH HEADER LINE, "DEVK939546
    STOT TYPE TOT_TAB WITH HEADER LINE, "DEVK939546
    OP,
    MAXMANDT LIKE DD_STIDA,
    MAXMANST TYPE P,
    SUMKLIMB TYPE P,
    SUMVLIBB TYPE P,
    VERZUG TYPE P,
    OBAD TYPE P,
    BLOCK_CNT TYPE P,
    INTENS,
    ONEBYTE(1) TYPE C,
    TAGE1A LIKE RFPDO1-ALLGFAEL,
    TAGE2A LIKE RFPDO1-ALLGFAEL,
    TAGE3A LIKE RFPDO1-ALLGFAEL,
    HOLD_KUNNR LIKE KNA1-KUNNR, "tonyc
    HOLD_SUPER LIKE KNA1-KUNNR, "tonyc
    HOLD_REP2 LIKE KNA1-KUNNR, "tonyc
    SUPER_REP LIKE KNA1-KUNNR, "tonyc
    TEMP_TELF1 LIKE KNA1-TELF1, "JAM
    IT_T014 LIKE T014 OCCURS 0 WITH HEADER LINE, "JAM
    G_KLIMK_TXT LIKE GTAB-KLIMK_TXT, "JAM
    G_WAERS LIKE GTAB-WAERS, "JAM
    G_CONT_NAME(50) TYPE C. "JA
    DATA FILL_REP_INFO.
    BC SUNILP 05/14/2007
    DATA: BEGIN OF ITAB_VBRP OCCURS 0.
    INCLUDE STRUCTURE VBRP.
    DATA: END OF ITAB_VBRP.
    DATA: T_PERC TYPE F,
    SUM_NETWR LIKE VBRP-NETWR.
    *DATA: GTAB_LINES LIKE GTAB OCCURS 0 WITH HEADER LINE.
    DATA: BEGIN OF GTAB_LINES OCCURS 0.
    INCLUDE STRUCTURE GTAB.
    DATA: IND(1),
    OBAD TYPE P.
    DATA: END OF GTAB_LINES.
    DATA: BEGIN OF ITAB_VBRP1 OCCURS 0,
    VBELN LIKE VBRP-VBELN,
    NETWR LIKE VBRP-NETWR,
    ZZMREP LIKE VBRP-ZZMREP, "Super Rep
    ZZLREP LIKE VBRP-ZZLREP, "Rep
    PERC TYPE F,
    END OF ITAB_VBRP1.
    EC SUNILP 05/14/2007
    BEGIN_OF_BLOCK 2.
    PARAMETERS: REGIO LIKE KNA1-REGIO.
    PARAMETERS: CONSOL AS CHECKBOX. "TONYC
    PARAMETERS: P_KKBER AS CHECKBOX, "TONYC
    P_CONV AS CHECKBOX. "tonyc issue #3047
    PARAMETERS: SUMMEN LIKE RFPDO1-ALLGSUMM,
    TAGE1 LIKE RFPDO1-ALLGFAEL DEFAULT '30',
    TAGE2 LIKE RFPDO1-ALLGFAEL DEFAULT '60',
    TAGE3 LIKE RFPDO1-ALLGFAEL DEFAULT '90',
    TAGE4 LIKE RFPDO1-ALLGFAEL DEFAULT '120'.
    END_OF_BLOCK 2.
    BEGIN_OF_BLOCK 3.
    SELECT-OPTIONS: P_SUPREP FOR KNVP-KUNNR, "Super REP "DEVK939546
    P_REP FOR KNVP-KUNNR, "SALES REP "DEVK939546
    P_VKORG FOR TVKO-VKORG, "TONYC ISSUE 4743
    P_LOTKZ FOR BKPF-LOTKZ. "TONYC ISSUE 4743
    END_OF_BLOCK 3.
    INITIALIZATION. "JAM
    PERFORM LOAD_T014. "JAM
    refresh dd_augdt.
    clear dd_augdt.
    dd_augdt-option = 'EQ'.
    dd_augdt-sign = 'I'.
    dd_augdt-low = ' '.
    append dd_augdt.
    AT SELECTION-SCREEN.
    IF CONSOL = 'X'.
    IF NOT P_SUPREP[] IS INITIAL. "DEVK939546
    MESSAGE E999 WITH 'Consolidated report not allowed w/ Super Rep'.
    ENDIF.
    ENDIF.
    CHECK IF THE REP INFO IS ADDED OR NOT - VS
    IF NOT P_SUPREP IS INITIAL OR"TONY ISSUE 4743
    NOT P_REP IS INITIAL."TONY ISSUE 4743
    FILL_REP_INFO = 'X'."TONY ISSUE 4743
    ENDIF."TONY ISSUE 4743
    START-OF-SELECTION.
    get_frame_title 2.
    add function module to track usage JD 10/13/98 *****
    CALL FUNCTION 'Z_RUN_LOG'
    EXCEPTIONS
    OTHERS = 1.
    *IF NOT P_SUPREP IS INITIAL AND NOT P_REP IS INITIAL.
    P_SUPREP = ' '.
    *ENDIF.
    GET KNA1 FIELDS LAND1 REGIO KUNNR NAME1 NAME2 ORT01 TELF1. "JAM
    new-page.
    skip.
    TEMP_TELF1 = KNA1-TELF1.
    MAXMANDT = '19000101'.
    MAXMANST = 0.
    SUMVLIBB = 0.
    PERFORM GET_CUST_CONTACT. "JAM
    Check sales rep- NES071797
    Get any valid record and exit.
    IF NOT p_suprep[] IS INITIAL. "DEVK939546 "TONY ISSUE 4743 start
    good_super_rep = ' '.
    SELECT kunn2 INTO super_rep FROM knvp UP TO 1 ROWS
    WHERE
    kunnr = kna1-kunnr AND
    parvw = 'ZS' AND
    kunn2 IN p_suprep.
    EXIT.
    ENDSELECT.
    IF sy-subrc = 0.
    good_super_rep = 'X'.
    gtab-super = super_rep.
    super_rep = ' '.
    ENDIF.
    CHECK good_super_rep = 'X'.
    SELECT kunn2 INTO gtab-rep FROM knvp UP TO 1 ROWS
    WHERE
    kunnr = kna1-kunnr AND
    parvw = 'ZR' AND
    kunn2 IN p_rep.
    EXIT.
    ENDSELECT.
    CHECK sy-subrc = 0.
    ELSEIF NOT p_rep[] IS INITIAL. "DEVK939546
    SELECT kunn2 INTO gtab-rep FROM knvp UP TO 1 ROWS
    WHERE
    kunnr = kna1-kunnr AND
    parvw = 'ZR' AND
    kunn2 IN p_rep.
    EXIT.
    ENDSELECT.
    CHECK sy-subrc = 0.
    ENDIF. "TONY ISSUE 4743 end
    GET KNB1 FIELDS BUKRS VLIBB ZTERM. "tonyc #2500
    GTAB-BUKRS = KNB1-BUKRS.
    GTAB-ZTERM = KNB1-ZTERM.
    SUMVLIBB = SUMVLIBB + KNB1-VLIBB.
    GET KNB5.
    IF KNB5-MADAT > MAXMANDT.
    MAXMANDT = KNB5-MADAT.
    ENDIF.
    IF KNB5-MAHNS > MAXMANST.
    MAXMANST = KNB5-MAHNS.
    ENDIF.
    SUMKLIMB = SUMKLIMB + KLIMB.
    GET BSID.
    CHECK BSID-BSTAT = SPACE.
    field was intended for Business Area, changed to use Currency
    GTAB-GSBER = BSID-WAERS.
    IF P_KKBER = 'X'. "TONYC ISSUE #2500
    IF BSID-KKBER = ' '.
    GTAB-KKBER = BSID-BUKRS.
    ELSE.
    GTAB-KKBER = BSID-KKBER. "TONYC ISSUE #2500
    ENDIF.
    ENDIF. "TONYC ISSUE #2500
    SELECT SINGLE * FROM BKPF "TONY ISSUE 4743
    WHERE BUKRS = BSID-BUKRS "TONY ISSUE 4743
    AND BELNR = BSID-BELNR "TONY ISSUE 4743
    AND GJAHR = BSID-GJAHR. "TONY ISSUE 4743
    BC SUNILP 05/14/2007
    IF BKPF-XREF2_HD IS NOT INITIAL.
    CHECK BKPF-XREF2_HD IN P_SUPREP. "TONY ISSUE 4743
    ELSE.
    IF P_REP[] IS INITIAL.
    REFRESH: ITAB_VBRP, ITAB_VBRP1.
    IF NOT BKPF-XBLNR IS INITIAL.
    SELECT * FROM VBRP INTO ITAB_VBRP WHERE VBELN = BKPF-XBLNR.
    APPEND ITAB_VBRP. CLEAR ITAB_VBRP.
    ENDSELECT.
    CHECK ITAB_VBRP[] IS NOT INITIAL.
    CLEAR: SUM_NETWR.
    LOOP AT ITAB_VBRP.
    CHECK ITAB_VBRP-ZZMREP IN P_SUPREP.
    CHECK ITAB_VBRP-ZZLREP IN P_REP.
    MOVE-CORRESPONDING ITAB_VBRP TO ITAB_VBRP1.
    COLLECT: ITAB_VBRP1.
    SUM_NETWR = SUM_NETWR + ITAB_VBRP-NETWR.
    CLEAR ITAB_VBRP.
    ENDLOOP.
    CHECK ITAB_VBRP1[] IS NOT INITIAL.
    LOOP AT ITAB_VBRP1.
    CLEAR: T_PERC.
    T_PERC = ( ITAB_VBRP1-NETWR / SUM_NETWR ).
    ITAB_VBRP1-PERC = T_PERC.
    MODIFY ITAB_VBRP1 INDEX SY-TABIX TRANSPORTING PERC.
    ENDLOOP.
    ENDIF.
    ENDIF.
    ENDIF.
    EC SUNILP 05/14/2007
    IF FILL_REP_INFO = 'X'.
    GTAB-SUPER = BKPF-XREF2_HD. "TONY ISSUE 4743 "MOVE THE CONTENTS OF XREF2_HD TO GTAB INTERNAL TABLE - VS
    ENDIF.
    BC SUNILP 05/14/2007
    IF BKPF-XREF1_HD IS NOT INITIAL.
    CHECK BKPF-XREF1_HD IN P_REP. "TONY ISSUE 4743 " ELSE MOVE THE CONTENTS OF - VS
    ELSE.
    REFRESH: ITAB_VBRP, ITAB_VBRP1.
    IF NOT BKPF-XBLNR IS INITIAL.
    SELECT * FROM VBRP INTO ITAB_VBRP WHERE VBELN = BKPF-XBLNR.
    APPEND ITAB_VBRP. CLEAR ITAB_VBRP.
    ENDSELECT.
    CHECK ITAB_VBRP[] IS NOT INITIAL.
    CLEAR: SUM_NETWR.
    LOOP AT ITAB_VBRP.
    CHECK ITAB_VBRP-ZZMREP IN P_SUPREP.
    CHECK ITAB_VBRP-ZZLREP IN P_REP.
    MOVE-CORRESPONDING ITAB_VBRP TO ITAB_VBRP1.
    COLLECT: ITAB_VBRP1.
    SUM_NETWR = SUM_NETWR + ITAB_VBRP-NETWR.
    CLEAR ITAB_VBRP.
    ENDLOOP.
    CHECK ITAB_VBRP1[] IS NOT INITIAL.
    LOOP AT ITAB_VBRP1.
    CLEAR: T_PERC.
    T_PERC = ( ITAB_VBRP1-NETWR / SUM_NETWR ).
    ITAB_VBRP1-PERC = T_PERC.
    MODIFY ITAB_VBRP1 INDEX SY-TABIX TRANSPORTING PERC.
    ENDLOOP.
    ENDIF.
    ENDIF.
    EC SUNILP 05/14/2007
    IF FILL_REP_INFO = 'X'.
    GTAB-REP = BKPF-XREF1_HD. "TONY ISSUE 4743
    ENDIF.
    CHECK BKPF-LOTKZ IN P_LOTKZ. "TONY ISSUE 4743
    CHECK BKPF-BRNCH IN P_VKORG. "TONY ISSUE 4743
    SELECT SINGLE FILKD INTO GTAB-FILKD FROM BSEG
    WHERE BUKRS = BSID-BUKRS
    AND BELNR = BSID-BELNR
    AND GJAHR = BSID-GJAHR
    AND BUZEI = BSID-BUZEI.
    gtab-gsber = bsid-gsber.
    get rep info for each bsid record
    IF NOT P_SUPREP IS INITIAL. "tonyc
    SELECT KUNNR FROM VBPA INTO HOLD_REP UP TO 1 ROWS "tonyc
    WHERE VBELN = BSID-VBELN "tonyc
    AND PARVW = 'ZR'. "tonyc
    ENDSELECT. "tonyc
    IF NOT P_REP IS INITIAL. "tonyc
    CHECK HOLD_REP = P_REP. "tonyc
    ENDIF. "tonyc
    GTAB-REP = HOLD_REP. "tonyc
    HOLD_REP = ' '. "tonyc
    ENDIF. "tonyc
    PERFORM GET_KNKK_INFO. "JAM
    GTAB-KLIMK_TXT = G_KLIMK_TXT.
    GTAB-WAERS = G_WAERS.
    GTAB-LAND1 = KNA1-LAND1.
    GTAB-REGIO = KNA1-REGIO.
    GTAB-KUNNR = KNA1-KUNNR.
    GTAB-NAME1 = KNA1-NAME1.
    GTAB-NAME2 = KNA1-NAME2.
    GTAB-ORT01 = KNA1-ORT01.
    *if there is no phone number for the contact, pull the phone
    *number from the sold-to
    IF KNVK-TELF1 = ' '.
    GTAB-TELF1 = TEMP_TELF1.
    ELSE.
    GTAB-TELF1 = KNVK-TELF1. "JAM
    ENDIF.
    GTAB-CONT_NAME1 = KNVK-NAME1.
    GTAB-NAMEV = KNVK-NAMEV.
    verzug = bsega-netdt - dd_stida.
    VERZUG = DD_STIDA - BSEGA-NETDT. "days past due calculation
    OP = 'X'.
    GTAB-RAST2 = GTAB-RAST3 = GTAB-RAST4 = 0.
    GTAB-RAST5 = GTAB-RAST6 = OBAD = GTAB-RAST7 = 0.
    IF VERZUG LE 0. "future due
    GTAB-RAST1 = BSEGA-WRSHB.
    ELSE.
    IF VERZUG LE TAGE1. "past due 1 to tage1 days
    GTAB-RAST1 = BSEGA-WRSHB.
    GTAB-RAST2 = BSEGA-WRSHB.
    OBAD = BSEGA-WRSHB.
    ELSE.
    IF VERZUG LE TAGE2. "past due tage1 to tage2 days
    GTAB-RAST1 = BSEGA-WRSHB.
    GTAB-RAST3 = BSEGA-WRSHB.
    OBAD = BSEGA-WRSHB.
    ELSE.
    IF VERZUG LE TAGE3. "past due tage2 to tage3 days
    GTAB-RAST1 = BSEGA-WRSHB.
    GTAB-RAST4 = BSEGA-WRSHB.
    OBAD = BSEGA-WRSHB.
    ELSE.
    IF VERZUG LE TAGE4. "past due tage3 to tage4 days
    GTAB-RAST1 = BSEGA-WRSHB.
    GTAB-RAST5 = BSEGA-WRSHB.
    OBAD = BSEGA-WRSHB.
    ELSE.
    IF VERZUG GT TAGE4. "past due > tage4 days
    GTAB-RAST1 = BSEGA-WRSHB.
    GTAB-RAST6 = BSEGA-WRSHB.
    OBAD = BSEGA-WRSHB.
    ENDIF.
    ENDIF.
    ENDIF.
    ENDIF.
    ENDIF.
    ENDIF.
    GTAB-RAST7 = GTAB-RAST1 - OBAD.
    stab = gtab.
    MOVE-CORRESPONDING GTAB TO STAB.
    BC SUNILP 05/15/2007
    IF ITAB_VBRP1[] IS NOT INITIAL.
    GTAB-T_IND = 'X'.
    LOOP AT ITAB_VBRP1.
    MOVE-CORRESPONDING GTAB TO GTAB_LINES.
    GTAB_LINES-SORT_GSB = '1'.
    GTAB_LINES-SUPER = ITAB_VBRP1-ZZMREP.
    GTAB_LINES-REP = ITAB_VBRP1-ZZLREP.
    GTAB_LINES-RAST1 = GTAB_LINES-RAST1 * ITAB_VBRP1-PERC.
    GTAB_LINES-RAST2 = GTAB_LINES-RAST2 * ITAB_VBRP1-PERC.
    GTAB_LINES-RAST3 = GTAB_LINES-RAST3 * ITAB_VBRP1-PERC.
    GTAB_LINES-RAST4 = GTAB_LINES-RAST4 * ITAB_VBRP1-PERC.
    GTAB_LINES-RAST5 = GTAB_LINES-RAST5 * ITAB_VBRP1-PERC.
    GTAB_LINES-RAST6 = GTAB_LINES-RAST6 * ITAB_VBRP1-PERC.
    GTAB_LINES-RAST7 = GTAB_LINES-RAST7 * ITAB_VBRP1-PERC.
    GTAB_LINES-OBAD = GTAB_LINES-OBAD * ITAB_VBRP1-PERC.
    COLLECT: GTAB_LINES.
    ENDLOOP.
    ELSE.
    MOVE-CORRESPONDING GTAB TO GTAB_LINES.
    GTAB_LINES-T_IND = 'X'.
    GTAB_LINES-SORT_GSB = '1'.
    IF GTAB_LINES-SUPER IN P_SUPREP OR GTAB_LINES-REP IN P_REP.
    COLLECT: GTAB_LINES.
    ENDIF.
    ENDIF.
    EC SUNILP 05/15/2007
    gtab-sort_gsb = stab-sort_gsb = '0'.
    collect: gtab, stab.
    gtab-gsber = stab-gsber = '****'.
    GTAB-SORT_GSB = '1'.
    IF REGIO = SPACE OR REGIO = GTAB-REGIO.
    IF GTAB_LINES-SUPER IN P_SUPREP OR GTAB_LINES-REP IN P_REP.
    COLLECT: GTAB, STAB.
    ENDIF.
    ENDIF.
    END-OF-SELECTION.
    TAGE1A = TAGE1 + 1.
    TAGE2A = TAGE2 + 1.
    TAGE3A = TAGE3 + 1.
    IF SUMMEN = ' '.
    sort gtab by bukrs land1 regio kunnr gsber sort_gsb.
    sort gtab by bukrs land1 regio name1 kunnr gsber sort_gsb. "JAM
    IF CONSOL = 'X'.
    SORT GTAB BY LAND1 REGIO NAME1 KUNNR BUKRS KKBER GSBER SORT_GSB.
    "TONYC
    REPORT_TYPE = 'consolidated'.
    ELSEIF NOT P_SUPREP[] IS INITIAL. "DEVK939546
    SORT GTAB
    BY SUPER REP NAME1 BUKRS KKBER LAND1 REGIO NAME1 GSBER SORT_GSB.
    BC SUNILP 05/15/2007
    SORT GTAB_LINES
    BY SUPER REP NAME1 BUKRS KKBER LAND1 REGIO NAME1 GSBER SORT_GSB.
    EC SUNILP 05/15/2007
    REPORT_TYPE = 'super rep'.
    CLEAR STAB. "tonyc 03/06/2004
    REFRESH STAB. "tonyc 03/06/2004
    ELSEIF NOT P_REP[] IS INITIAL. "DEVK939546
    SORT GTAB "DEVK939546
    BY REP NAME1 BUKRS KKBER LAND1 REGIO NAME1 GSBER SORT_GSB.
    "DEVK939546
    BC SUNILP 05/15/2007
    SORT GTAB_LINES
    BY REP NAME1 BUKRS KKBER LAND1 REGIO NAME1 GSBER SORT_GSB.
    EC SUNILP 05/15/2007
    REPORT_TYPE = 'rep'. "DEVK939546
    CLEAR STAB. "tonyc 03/06/2004
    REFRESH STAB. "tonyc 03/06/2004
    ELSE.
    SORT GTAB BY BUKRS KKBER LAND1 REGIO NAME1 KUNNR GSBER SORT_GSB.
    BC SUNILP 05/15/2007
    SORT GTAB_LINES BY BUKRS KKBER LAND1 REGIO NAME1 KUNNR GSBER SORT_GSB.
    EC SUNILP 05/15/2007
    REPORT_TYPE = 'regular'.
    ENDIF.
    BC SUNILP 05/15/2007
    DELETE ADJACENT DUPLICATES FROM GTAB COMPARING BUKRS NAME1.
    LOOP AT GTAB_LINES.
    IF P_REP[] IS INITIAL.
    IF GTAB_LINES-SUPER NOT IN P_SUPREP.
    DELETE GTAB_LINES.
    ENDIF.
    ELSE.
    IF GTAB_LINES-SUPER NOT IN P_SUPREP OR GTAB_LINES-REP NOT IN P_REP.
    DELETE GTAB_LINES.
    ENDIF.
    ENDIF.
    ENDLOOP.
    LOOP AT GTAB.
    READ TABLE GTAB_LINES WITH KEY BUKRS = GTAB-BUKRS
    NAME1 = GTAB-NAME1.
    IF SY-SUBRC NE '0'.
    DELETE GTAB.
    ENDIF.
    ENDLOOP.
    EC SUNILP 05/15/2007
    LOOP AT GTAB.
    MOVE GTAB-BUKRS TO T001-BUKRS. READ TABLE T001.
    RESERVE 5 LINES.
    CASE REPORT_TYPE.
    WHEN 'regular'.
    IF HOLD_BUKRS <> GTAB-BUKRS.
    IF SY-TABIX > 1. "TONYC
    NEW-PAGE. SKIP. "TONYC
    ENDIF. "TONYC
    ENDIF.
    PERFORM WRITE_CUST_INFO. "TONYC
    PERFORM WRITE_DETAIL.
    hold_bukrs = gtab-bukrs. "tonyc
    WHEN 'consolidated'.
    IF HOLD_KUNNR <> GTAB-KUNNR. "TONYC
    PERFORM WRITE_CUST_INFO. "TONYC
    ENDIF. "TONYC
    HOLD_KUNNR = GTAB-KUNNR. "TONYC
    PERFORM WRITE_DETAIL.
    WHEN 'super rep'.
    IF GTAB-T_IND NE 'X'.
    BC SUNILP 05/22/2007
    READ TABLE GTAB_LINES WITH KEY BUKRS = GTAB-BUKRS
    NAME1 = GTAB-NAME1.
    EC SUNILP 05/22/2007
    IF ( HOLD_SUPER <> GTAB_LINES-SUPER ) OR
    ( HOLD_REP2 <> GTAB_LINES-REP ).
    NEW-PAGE.
    PERFORM GET_AND_WRITE_SUPERINFO.
    ENDIF.
    HOLD_REP2 = GTAB_LINES-REP.
    HOLD_SUPER = GTAB_LINES-SUPER.
    IF HOLD_KUNNR <> GTAB-KUNNR. "TONYC
    WRITE :/. "TONYC
    ULINE. "TONYC
    PERFORM WRITE_CUST_INFO. "TONYC
    ENDIF. "TONYC
    HOLD_KUNNR = GTAB-KUNNR. "TONYC
    PERFORM WRITE_DETAIL. "TONYC
    AT END OF REP. "DEVK939546
    SKIP. "DEVK939546
    RESERVE 7 LINES. "DEVK939546
    FORMAT COLOR COL_TOTAL INTENSIFIED. "DEVK939546
    WRITE: / 'Summary for Rep:', "DEVK939546
    GTAB-REP, '/', REP_NAME, 132 ONEBYTE."DEVK939546
    PERFORM WRITE_TOTS TABLES RTOT. "DEVK939546
    REFRESH RTOT. "DEVK939546
    ENDAT. "DEVK939546
    AT END OF SUPER. "DEVK939546
    CLEAR STAB. "tonyc 03/06/2004
    REFRESH STAB. "tonyc 03/06/2004
    NEW-PAGE. SKIP. "DEVK939546
    FORMAT COLOR COL_TOTAL INTENSIFIED. "DEVK939546
    WRITE: / 'Summary for Super Rep:', "DEVK939546
    GTAB-SUPER, '/', SUPER_NAME, 132 ONEBYTE."DEVK939546
    PERFORM WRITE_TOTS TABLES STOT. "DEVK939546
    REFRESH STOT. "DEVK939546
    ENDAT. "DEVK939546
    ELSE.
    LOOP AT GTAB_LINES WHERE BUKRS = GTAB-BUKRS
    AND NAME1 = GTAB-NAME1.
    IF ( HOLD_SUPER <> GTAB_LINES-SUPER ) OR
    ( HOLD_REP2 <> GTAB_LINES-REP ).
    NEW-PAGE.
    PERFORM GET_AND_WRITE_SUPERINFO.
    ENDIF.
    HOLD_REP2 = GTAB_LINES-REP.
    HOLD_SUPER = GTAB_LINES-SUPER.
    IF HOLD_KUNNR <> GTAB_LINES-KUNNR.
    WRITE :/.
    ULINE.
    PERFORM WRITE_CUST_INFO.
    ENDIF.
    HOLD_KUNNR = GTAB_LINES-KUNNR.
    PERFORM WRITE_DETAIL.
    AT END OF REP.
    SKIP.
    RESERVE 7 LINES.
    FORMAT COLOR COL_TOTAL INTENSIFIED.
    WRITE: / 'Summary for Rep:',
    GTAB_LINES-REP, '/', REP_NAME, 132 ONEBYTE.
    PERFORM WRITE_TOTS TABLES RTOT.
    REFRESH RTOT.
    ENDAT.
    AT END OF SUPER.
    CLEAR STAB. "tonyc 03/06/2004
    REFRESH STAB. "tonyc 03/06/2004
    NEW-PAGE. SKIP.
    FORMAT COLOR COL_TOTAL INTENSIFIED.
    WRITE: / 'Summary for Super Rep:',
    GTAB_LINES-SUPER, '/', SUPER_NAME, 132 ONEBYTE.
    PERFORM WRITE_TOTS TABLES STOT.
    REFRESH STOT.
    ENDAT.
    ENDLOOP.
    ENDIF.
    WHEN 'rep'. "DEVK939546
    LOOP AT GTAB_LINES WHERE BUKRS = GTAB-BUKRS
    AND NAME1 = GTAB-NAME1.
    IF HOLD_REP2 <> GTAB_LINES-REP. "DEVK939546
    NEW-PAGE. "DEVK939546
    PERFORM GET_AND_WRITE_REPINFO. "DEVK939546
    ENDIF. "DEVK939546
    HOLD_REP2 = GTAB_LINES-REP. "DEVK939546
    IF HOLD_KUNNR <> GTAB_LINES-KUNNR. "DEVK939546
    WRITE :/. "DEVK939546
    ULINE. "DEVK939546
    PERFORM WRITE_CUST_INFO. "DEVK939546
    ENDIF. "DEVK939546
    HOLD_KUNNR = GTAB_LINES-KUNNR. "DEVK939546
    PERFORM WRITE_DETAIL. "DEVK939546
    AT END OF REP. "DEVK939546
    SKIP. "DEVK939546
    RESERVE 7 LINES. "DEVK939546
    FORMAT COLOR COL_TOTAL INTENSIFIED. "DEVK939546
    WRITE: / 'Summary for Rep:', "DEVK939546
    GTAB_LINES-REP, '/', REP_NAME, 132 ONEBYTE."DEVK939546
    PERFORM WRITE_TOTS TABLES RTOT. "DEVK939546
    REFRESH RTOT. "DEVK939546
    ENDAT. "DEVK939546
    ENDLOOP.
    ENDCASE.
    ENDLOOP.
    ENDIF.
    OP = ' '.
    REFRESH GTAB.
    IF NOT REPORT_TYPE = 'super rep'.
    ULINE.
    ENDIF.
    SKIP 1.
    IF SUMMEN = ' '. "if 'output totals only' bypass new-page
    NEW-PAGE. SKIP.
    ENDIF.
    WRITE: /25 TEXT-030, 132 ONEBYTE, /25 TEXT-031, 132 ONEBYTE.
    PERFORM WRITE_TOTS TABLES STAB. "DEVK939546
    TOP-OF-PAGE.
    INTENS = SPACE.
    FORMAT COLOR COL_HEADING INTENSIFIED ON.
    WRITE: / SY-VLINE, 1 TEXT-001, DD_STIDA, 75 TEXT-051, 132 SY-VLINE.
    ULINE.
    WRITE: / SY-VLINE, 13 SY-VLINE, 30 SY-VLINE,
    47 SY-VLINE, 58 TEXT-003, 81 SY-VLINE,
    92 TEXT-003, 115 SY-VLINE, 118 TEXT-003, 132 SY-VLINE,
    / SY-VLINE, 02 TEXT-004, 13 SY-VLINE, TEXT-002,
    30 SY-VLINE, 32 TEXT-018, 47 SY-VLINE,
    50 '1', 54 TEXT-040, 57 TAGE1, 64 SY-VLINE, " 65 tage2,
    67 TAGE1A, 72 TEXT-040, 75 TAGE2,
    81 SY-VLINE, 83 TAGE2A, 89 TEXT-040, 91 TAGE3, 98 SY-VLINE,
    101 TAGE3A, 107 TEXT-040, 110 TAGE4, 115 SY-VLINE,
    117 TAGE4, 123 TEXT-017, 132 SY-VLINE.
    ULINE.
    SKIP 1.
    SUMMARY.
    FORMAT COLOR COL_HEADING INTENSIFIED OFF.
    FORM write_tots *
    --> PTAB *
    FORM WRITE_TOTS TABLES PTAB TYPE TOT_TAB. "DEVK939546
    CLEAR INTENS. "DEVK939546
    FORMAT COLOR COL_HEADING INTENSIFIED OFF. "DEVK939546
    IF P_CONV = 'X'. "tonyc issue #3047 begin
    WRITE /4 TEXT-101.
    WRITE: /4 TEXT-102,
    50 TEXT-100.
    ENDIF. "tonyc issue #3047 end
    ULINE. "DEVK939546
    SORT PTAB BY BUKRS GSBER. "DEVK939546
    LOOP AT PTAB. "DEVK939546
    IF SY-TABIX > 1.
    WRITE_TOTAL = 'X'.
    ENDIF.
    MOVE PTAB-BUKRS TO T001-BUKRS. READ TABLE T001. "DEVK939546
    MOVE PTAB-GSBER TO T001-WAERS. "DEVK939546
    IF P_CONV = 'X'. "tonyc issue #3047 begin
    PERFORM CONVERT_VALUES USING STAB-RAST1
    STAB-GSBER.
    PERFORM CONVERT_VALUES USING STAB-RAST2
    STAB-GSBER.
    PERFORM CONVERT_VALUES USING STAB-RAST3
    STAB-GSBER.
    PERFORM CONVERT_VALUES USING STAB-RAST4
    STAB-GSBER.
    PERFORM CONVERT_VALUES USING STAB-RAST5
    STAB-GSBER.
    PERFORM CONVERT_VALUES USING STAB-RAST6
    STAB-GSBER.
    PERFORM CONVERT_VALUES USING STAB-RAST7
    STAB-GSBER.
    ENDIF. "TOnyc issue #3047 end
    MOVE-CORRESPONDING PTAB TO STAB.
    COLLECT STAB.
    IF P_KKBER = 'X'. "TONYC ISSUE #2500
    CLEAR HOLD_KKBER_DESC2.
    SELECT SINGLE KKBTX INTO HOLD_KKBER_DESC2 FROM T014T
    WHERE KKBER = STAB-KKBER AND
    SPRAS = 'E'.
    IF SY-SUBRC <> '0'.
    HOLD_KKBER_DESC2 = 'Undetermined'.
    ENDIF.
    FORMAT COLOR OFF.
    WRITE: / SY-VLINE.
    FORMAT COLOR COL_HEADING INTENSIFIED OFF.
    WRITE: 6 STAB-GSBER, HOLD_KKBER_DESC2, SY-VLINE.
    ULINE.
    FORMAT COLOR OFF.
    WRITE: / SY-VLINE.
    FORMAT COLOR COL_HEADING INTENSIFIED OFF.
    IF P_CONV = 'X'. "tonyc issue #3047 begin
    T001-WAERS = 'USD'.
    ENDIF. "tonyc issue #3047 end
    WRITE: 13 STAB-RAST1 NO-ZERO CURRENCY T001-WAERS, SY-VLINE,
    (14) STAB-RAST7 NO-ZERO CURRENCY T001-WAERS, SY-VLINE,
    (14) STAB-RAST2 NO-ZERO CURRENCY T001-WAERS, SY-VLINE,
    (14) STAB-RAST3 NO-ZERO CURRENCY T001-WAERS, SY-VLINE,
    (14) STAB-RAST4 NO-ZERO CURRENCY T001-WAERS, SY-VLINE,
    (14) STAB-RAST5 NO-ZERO CURRENCY T001-WAERS, SY-VLINE,
    (14) STAB-RAST6 NO-ZERO CURRENCY T001-WAERS, SY-VLINE.
    HOLD_BUKRS2 = STAB-BUKRS. "TONYC ISSUE #2500
    ULINE.
    FORMAT COLOR OFF.
    TOTAL_RAST1 = STAB-RAST1 + TOTAL_RAST1.
    TOTAL_RAST2 = STAB-RAST2 + TOTAL_RAST2.
    TOTAL_RAST3 = STAB-RAST3 + TOTAL_RAST3.
    TOTAL_RAST4 = STAB-RAST4 + TOTAL_RAST4.
    TOTAL_RAST5 = STAB-RAST5 + TOTAL_RAST5.
    TOTAL_RAST6 = STAB-RAST6 + TOTAL_RAST6.
    TOTAL_RAST7 = STAB-RAST7 + TOTAL_RAST7.
    ELSE.
    FORMAT COLOR COL_NORMAL INTENSIFIED OFF. "DEVK939546
    IF INTENS = SPACE. "DEVK939546
    FORMAT COLOR COL_NORMAL INTENSIFIED OFF. "DEVK939546
    INTENS = 'X'. "DEVK939546
    ELSE. "DEVK939546
    FORMAT COLOR COL_NORMAL INTENSIFIED ON. "DEVK939546
    INTENS = SPACE. "DEVK939546
    ENDIF. "DEVK939546
    WRITE: / SY-VLINE, PTAB-BUKRS, PTAB-GSBER, SY-VLINE, "DEVK939546
    (14) PTAB-RAST1 NO-ZERO CURRENCY T001-WAERS, SY-VLINE,"DEVK939546
    (14) PTAB-RAST7 NO-ZERO CURRENCY T001-WAERS, SY-VLINE,"DEVK939546
    (14) PTAB-RAST2 NO-ZERO CURRENCY T001-WAERS, SY-VLINE,"DEVK939546
    (14) PTAB-RAST3 NO-ZERO CURRENCY T001-WAERS, SY-VLINE,"DEVK939546
    (14) PTAB-RAST4 NO-ZERO CURRENCY T001-WAERS, SY-VLINE,"DEVK939546
    (14) PTAB-RAST5 NO-ZERO CURRENCY T001-WAERS, SY-VLINE,"DEVK939546
    (14) PTAB-RAST6 NO-ZERO CURRENCY T001-WAERS, SY-VLINE."DEVK939546
    TOTAL_RAST1 = STAB-RAST1 + TOTAL_RAST1.
    TOTAL_RAST2 = STAB-RAST2 + TOTAL_RAST2.
    TOTAL_RAST3 = STAB-RAST3 + TOTAL_RAST3.
    TOTAL_RAST4 = STAB-RAST4 + TOTAL_RAST4.
    TOTAL_RAST5 = STAB-RAST5 + TOTAL_RAST5.
    TOTAL_RAST6 = STAB-RAST6 + TOTAL_RAST6.
    TOTAL_RAST7 = STAB-RAST7 + TOTAL_RAST7.
    ENDIF.
    ENDLOOP. "DEVK939546
    ULINE. "DEVK939546
    IF P_KKBER = 'X'. "TONYC ISSUE #2500
    IF P_CONV = 'X'. "tonyc issue #3047 begin
    FORMAT COLOR OFF.
    FORMAT COLOR COL_HEADING INTENSIFIED OFF.
    WRITE: SY-VLINE,
    6 'TOTAL ', SY-VLINE.
    ULINE.
    FORMAT COLOR OFF.
    WRITE: / SY-VLINE.
    FORMAT COLOR COL_HEADING INTENSIFIED OFF.
    WRITE: 13 TOTAL_RAST1 NO-ZERO CURRENCY T001-WAERS, SY-VLINE,
    (14) TOTAL_RAST7 NO-ZERO CURRENCY T001-WAERS, SY-VLINE,
    (14) TOTAL_RAST2 NO-ZERO CURRENCY T001-WAERS, SY-VLINE,
    (14) TOTAL_RAST3 NO-ZERO CURRENCY T001-WAERS, SY-VLINE,
    (14) TOTAL_RAST4 NO-ZERO CURRENCY T001-WAERS, SY-VLINE,
    (14) TOTAL_RAST5 NO-ZERO CURRENCY T001-WAERS, SY-VLINE,
    (14) TOTAL_RAST6 NO-ZERO CURRENCY T001-WAERS, SY-VLINE.
    ULINE.
    ENDIF. "tonyc issue #3047 end
    ELSE.
    IF P_CONV = 'X'.
    FORMAT COLOR OFF.
    FORMAT COLOR COL_HEADING INTENSIFIED OFF.
    WRITE: SY-VLINE,
    6 'TOTAL ', SY-VLINE.
    ULINE.
    FORMAT COLOR OFF.
    WRITE: / SY-VLINE.
    FORMAT COLOR COL_HEADING INTENSIFIED OFF.
    WRITE: 13 TOTAL_RAST1 NO-ZERO CURRENCY T001-WAERS, SY-VLINE,
    (14) TOTAL_RAST7 NO-ZERO CURRENCY T001-WAERS, SY-VLINE,
    (14) TOTAL_RAST2 NO-ZERO CURRENCY T001-WAERS, SY-VLINE,
    (14) TOTAL_RAST3 NO-ZERO CURRENCY T001-WAERS, SY-VLINE,
    (14) TOTAL_RAST4 NO-ZERO CURRENCY T001-WAERS, SY-VLINE,
    (14) TOTAL_RAST5 NO-ZERO CURRENCY T001-WAERS, SY-VLINE,
    (14) TOTAL_RAST6 NO-ZERO CURRENCY T001-WAERS, SY-VLINE.
    ULINE.
    ENDIF.
    ENDIF.
    SKIP 1. "DEVK939546
    ENDFORM. "DEVK939546
    *& Form GET_KNKK_INFO
    text
    --> p1 text
    <-- p2 text
    FORM GET_KNKK_INFO.
    CLEAR: G_WAERS,
    G_KLIMK_TXT,
    KNKK-KLIMK.
    get credit control area (KKBER) for comp code (BUKRS)
    SELECT SINGLE KLIMK
    INTO KNKK-KLIMK
    FROM KNKK
    WHERE KUNNR = KNA1-KUNNR AND
    KKBER = T001-KKBER.
    IF SY-SUBRC = 0.
    get currency for cred ctrl area
    CLEAR IT_T014.
    READ TABLE IT_T014 WITH KEY KKBER = T001-KKBER BINARY SEARCH.
    G_WAERS = IT_T014-WAERS.
    WRITE KNKK-KLIMK TO G_KLIMK_TXT CURRENCY G_WAERS.
    ENDIF.
    ENDFORM. " GET_KNKK_INFO
    *& Form SELECT_KNKK
    text
    -->P_KKBER Credit Limit Controlling Area
    <--P_FOUND_KNKK Indicates if record found
    FORM SELECT_KNKK USING P_KKBER
    CHANGING P_FOUND_KNKK.
    CLEAR: G_WAERS,
    G_KLIMK_TXT,
    KNKK-KLIMK.
    SELECT SINGLE KLIMK
    INTO KNKK-KLIMK
    FROM KNKK
    WHERE KUNNR = KNA1-KUNNR AND
    KKBER = P_KKBER.
    IF SY-SUBRC = 0.
    P_FOUND_KNKK = C_TRUE.
    get currency for cred ctrl area
    CLEAR IT_T014.
    READ TABLE IT_T014 WITH KEY KKBER = P_KKBER BINARY SEARCH.
    G_WAERS = IT_T014-WAERS.
    WRITE KNKK-KLIMK TO G_KLIMK_TXT CURRENCY G_WAERS.
    ELSE.
    P_FOUND_KNKK = C_FALSE.
    ENDIF.
    ENDFORM. " SELECT_KNKK
    *& Form GET_CUST_CONTACT & PHONE NUMBER
    FORM GET_CUST_CONTACT.
    CLEAR KNVK.
    C_CREDIT_ABTNR = '0003'. "look for contact in credit dept
    SELECT NAME1
    NAMEV
    TELF1
    INTO (KNVK-NAME1,
    KNVK-NAMEV,
    KNVK-TELF1)
    FROM KNVK
    WHERE KUNNR = KNA1-KUNNR AND
    ABTNR = C_CREDIT_ABTNR.
    ENDSELECT.
    If there wasn't a contact person for the credit dept, then just
    pull up the first contact info we find regardless of dept
    IF SY-SUBRC <> 0.
    CLEAR KNVK.
    SELECT NAME1
    NAMEV
    TELF1
    INTO (KNVK-NAME1,
    KNVK-NAMEV,
    KNVK-TELF1)
    FROM KNVK
    WHERE KUNNR = KNA1-KUNNR.
    IF SY-SUBRC = 0.
    EXIT.
    ENDIF.
    ENDSELECT.
    ELSE.
    EXIT.
    ENDIF. "not contact found in credit dept.
    ENDFORM. " GET_CUST_CONTACT
    *& Form LOAD_T014
    FORM LOAD_T014.
    SELECT *
    INTO TABLE IT_T014
    FROM T014.
    SORT IT_T014.
    ENDFORM. " LOAD_T014
    *& Form WRITE_CUST_INFO "TONYC
    text moved code and created a form. for cleaner code "TONYC
    --> p1 text
    <-- p2 text
    FORM WRITE_CUST_INFO.
    IF NOT REPORT_TYPE = 'super rep'.
    IF SY-TABIX > 1.
    ULINE.
    ENDIF.
    ENDIF.
    CONCATENATE GTAB-NAMEV "JAM
    GTAB-CONT_NAME1
    INTO G_CONT_NAME
    SEPARATED BY SPACE.
    FORMAT COLOR COL_TOTAL INTENSIFIED OFF.
    IF REPORT_TYPE = 'super rep'.
    IF GTAB-T_IND NE 'X'.
    WRITE: / GTAB-KUNNR, GTAB-NAME1, GTAB-ORT01, GTAB-REGIO, GTAB-LAND1,
    "g_cont_name,
    132 ONEBYTE.
    ELSE.
    WRITE: / GTAB_LINES-KUNNR, GTAB_LINES-NAME1, GTAB_LINES-ORT01, GTAB_LINES-REGIO, GTAB_LINES-LAND1,
    "g_cont_name,
    132 ONEBYTE.
    ENDIF.
    WRITE: /21 onebyte, 12 gtab-name2, 45 gtab-ort01,
    gtab-telf1, "gtab-klimk_txt, gtab-waers.
    132 onebyte.
    ELSE.
    WRITE: / GTAB-KUNNR, GTAB-NAME1, GTAB-ORT01, GTAB-REGIO, GTAB-LAND1,
    "g_cont_name, "JAM
    132 ONEBYTE.
    WRITE: /11 onebyte, 12 gtab-name2, 45 gtab-ort01,
    gtab-telf1, "gtab-klimk_txt, gtab-waers, "JAM
    132 onebyte.
    ENDIF.
    ENDFORM. " WRITE_CUST_INFO
    *& Form GET_AND_WRITE_SUPERINFO
    text
    --> p1 text
    <-- p2 text
    FORM GET_AND_WRITE_SUPERINFO.
    ULINE.
    IF GTAB-T_IND NE 'X'.
    SELECT SINGLE NAME1 FROM KNA1 INTO SUPER_NAME "TONYC
    WHERE KUNNR = GTAB-SUPER. "TONYC
    SELECT SINGLE NAME1 FROM KNA1 INTO REP_NAME "TONYC
    WHERE KUNNR = GTAB-REP. "TONYC
    CONCATENATE SUPER_NAME REP_NAME INTO REPS_INFO "TONYC
    SEPARATED BY BACKSLASH. "TONYC
    FORMAT COLOR COL_TOTAL INTENSIFIED. "TONYC
    WRITE:/ GTAB-SUPER, '/', "TONYC
    GTAB-REP, "TONYC
    25 REPS_INFO, 132 ONEBYTE. "TONYC
    ELSE.
    SELECT SINGLE NAME1 FROM KNA1 INTO SUPER_NAME
    WHERE KUNNR = GTAB_LINES-SUPER.
    SELECT SINGLE NAME1 FROM KNA1 INTO REP_NAME
    WHERE KUNNR = GTAB_LINES-REP.
    CONCATENATE SUPER_NAME REP_NAME INTO REPS_INFO
    SEPARATED BY BACKSLASH.
    FORMAT COLOR COL_TOTAL INTENSIFIED.
    WRITE:/ GTAB_LINES-SUPER, '/',
    GTAB_LINES-REP,
    25 REPS_INFO, 132 ONEBYTE.
    ENDIF.
    ENDFORM. " GET_AND_WRITE_SUPERINFO
    *& Form GET_AND_WRITE_REPINFO
    text
    --> p1 text
    <-- p2 text
    FORM GET_AND_WRITE_REPINFO.
    ULINE.
    SELECT SINGLE NAME1 FROM KNA1 INTO REP_NAME
    WHERE KUNNR = GTAB-REP.
    FORMAT COLOR COL_TOTAL INTENSIFIED.
    WRITE:/ GTAB-REP,
    25 REP_NAME, 132 ONEBYTE.
    ENDFORM. " GET_AND_WRITE_REPINFO
    *& Form WRITE_DETAIL
    text
    --> p1 text
    <-- p2 text
    FORM WRITE_DETAIL.
    clear z_description. "TONYC #2216
    move GTAB-KLIMK_TXT to z_hold_limit.
    IF z_hold_limit = 400.
    z_description = 'COD/Check'.
    elseif z_hold_limit = 500.
    z_description = 'COD/Cash'.
    elseif z_hold_limit = 600.
    z_description = 'Need Dealer Agree'.
    elseif z_hold_limit = 700.
    z_description = 'Need PDCs'.
    elseif z_hold_limit = 800.
    z_description = 'Need Fin Statements'.
    elseif z_hold_limit = 900.
    z_description = 'Past Due Balance'.
    elseif z_hold_limit = 1000.
    z_description = 'Miracle?'.
    endif. "TONYC #2216
    MOVE GTAB-GSBER TO T001-WAERS.
    FORMAT COLOR COL_TOTAL INTENSIFIED OFF.
    IF HOLD_KUNNR2 <> GTAB-KUNNR. "TONYC
    IF REPORT_TYPE = 'super rep'.
    WRITE: /3 ONEBYTE, GTAB-BUKRS.
    WRITE: 92 gtab-klimk_txt, gtab-waers, 132 onebyte. "TONYC
    WRITE: 92 gtab-klimk_txt, z_description,132 onebyte."TONYC #2500
    ELSE.
    WRITE: / ONEBYTE, GTAB-BUKRS.
    WRITE: 92 gtab-klimk_txt, z_description,132 onebyte."TONYC #2500
    WRITE: 92 gtab-klimk_txt, gtab-waers, 132 onebyte. "TONYC
    ENDIF.
    ENDIF.
    FORMAT COLOR COL_TOTAL INTENSIFIED OFF.
    IF P_KKBER = 'X'. "TONYC ISSUE# 2500
    CLEAR HOLD_KKBER_DESC.
    SELECT SINGLE KKBTX INTO HOLD_KKBER_DESC FROM T014T
    WHERE KKBER = GTAB-KKBER AND
    SPRAS = 'E'.
    IF SY-SUBRC <> '0'.
    HOLD_KKBER_DESC = 'Undetermined'.
    ENDIF.
    SELECT SINGLE KLIMK CTLPC
    INTO (HOLD_KLIMK, HOLD-CTLPC)
    FROM KNKK
    WHERE KUNNR = GTAB-KUNNR AND
    KKBER = GTAB-KKBER.
    SELECT SINGLE RTEXT INTO HOLD-CTLPC-TEXT FROM T691T
    WHERE SPRAS = 'EN' AND
    CTLPC = HOLD-CTLPC AND
    KKBER = GTAB-KKBER.
    WRITE HOLD_KLIMK TO HOLD_KLIMK2 CURRENCY GTAB-WAERS.
    WRITE: /7 GTAB-KKBER,
    12 HOLD_KKBER_DESC,
    80 HOLD_KLIMK2,
    103 GTAB-GSBER,
    108 HOLD-CTLPC-TEXT.
    ENDIF. "TONYC ISSUE# 2500
    FORMAT COLOR COL_NORMAL INTENSIFIED ON. "TONYC
    MOVE STAB-GSBER TO T001-WAERS.
    CLEAR HOLD_NAME.
    SELECT SINGLE NAME1 FROM KNA1 INTO HOLD_NAME
    WHERE KUNNR = GTAB-FILKD.
    WRITE: /15 GTAB-FILKD,
    30 HOLD_NAME.
    IF GTAB-T_IND NE 'X'.
    WRITE: /15(14) GTAB-RAST1 NO-ZERO CURRENCY T001-WAERS, ONEBYTE,
    (14) GTAB-RAST7 NO-ZERO CURRENCY T001-WAERS, ONEBYTE,
    (14) GTAB-RAST2 NO-ZERO CURRENCY T001-WAERS, ONEBYTE,
    (14) GTAB-RAST3 NO-ZERO CURRENCY T001-WAERS, ONEBYTE,
    (14) GTAB-RAST4 NO-ZERO CURRENCY T001-WAERS, ONEBYTE,
    (14) GTAB-RAST5 NO-ZERO CURRENCY T001-WAERS, ONEBYTE,
    (14) GTAB-RAST6 NO-ZERO CURRENCY T001-WAERS, ONEBYTE,
    132 ONEBYTE.
    ELSE.
    IF REPORT_TYPE NE 'super rep'.
    LOOP AT GTAB_LINES WHERE KUNNR = GTAB-KUNNR.
    WRITE: / GTAB_LINES-SUPER, ONEBYTE,
    15(14) GTAB_LINES-RAST1 NO-ZERO CURRENCY T001-WAERS, ONEBYTE,
    (14) GTAB_LINES-RAST7 NO-ZERO CURRENCY T001-WAERS, ONEBYTE,
    (14) GTAB_LINES-RAST2 NO-ZERO CURRENCY T001-WAERS, ONEBYTE,
    (14) GTAB_LINES-RAST3 NO-ZERO CURRENCY T001-WAERS, ONEBYTE,
    (14) GTAB_LINES-RAST4 NO-ZERO CURRENCY T001-WAERS, ONEBYTE,
    (14) GTAB_LINES-RAST5 NO-ZERO CURRENCY T001-WAERS, ONEBYTE,
    (14) GTAB_LINES-RAST6 NO-ZERO CURRENCY T001-WAERS, ONEBYTE,
    132 ONEBYTE.
    ENDLOOP.
    ELSE.
    WRITE: / GTAB_LINES-SUPER, ONEBYTE,
    15(14) GTAB_LINES-RAST1 NO-ZERO CURRENCY T001-WAERS, ONEBYTE,
    (14) GTAB_LINES-RAST7 NO-ZERO CURRENCY T001-WAERS, ONEBYTE,
    (14) GTAB_LINES-RAST2 NO-ZERO CURRENCY T001-WAERS, ONEBYTE,
    (14) GTAB_LINES-RAST3 NO-ZERO CURRENCY T001-WAERS, ONEBYTE,
    (14) GTAB_LINES-RAST4 NO-ZERO CURRENCY T001-WAERS, ONEBYTE,
    (14) GTAB_LINES-RAST5 NO-ZERO CURRENCY T001-WAERS, ONEBYTE,
    (14) GTAB_LINES-RAST6 NO-ZERO CURRENCY T001-WAERS, ONEBYTE,
    132 ONEBYTE.
    ENDIF.
    ENDIF.
    HOLD_BUKRS = GTAB-BUKRS. "Tonyc
    HOLD_KUNNR2 = GTAB-KUNNR. "TONYC
    HOLD_KKBER = GTAB-KKBER. "TONYC ISSUE #2500
    IF REPORT_TYPE = 'super rep' OR REPORT_TYPE = 'rep'. "DEVK939546
    IF GTAB-T_IND NE 'X'.
    MOVE-CORRESPONDING GTAB TO RTOT. "DEVK939546
    COLLECT RTOT. "DEVK939546
    ELSE.
    MOVE-CORRESPONDING GTAB_LINES TO RTOT.
    COLLECT RTOT.
    ENDIF.
    IF REPORT_TYPE = 'super rep'. "DEVK939546
    IF GTAB-T_IND NE 'X'.
    MOVE-CORRESPONDING GTAB TO STOT. "DEVK939546
    COLLECT STOT. "DEVK939546
    ELSE.
    MOVE-CORRESPONDING GTAB_LINES TO STOT.
    COLLECT STOT.
    ENDIF.
    ENDIF. "DEVK939546
    ENDIF. "DEVK939546
    ENDFORM. " WRITE_DETAIL
    *& Form convert_values
    text
    -->P_STAB_RAST1 text
    -->P_STAB_GSBER text
    FORM CONVERT_VALUES USING P_STAB_RAST1 "tonyc issue #3047 begin
    P_STAB-GSBER.
    CALL FUNCTION 'CONVERT_TO_LOCAL_CURRENCY'
    EXPORTING
    CLIENT = SY-MANDT
    DATE = SY-DATUM
    FOREIGN_AMOUNT = P_STAB_RAST1
    FOREIGN_CURRENCY = P_STAB-GSBER
    LOCAL_CURRENCY = 'USD'
    RATE = 0
    TYPE_OF_RATE = 'M'
    READ_TCURR = 'X'
    IMPORTING
    EXCHANGE_RATE =
    FOREIGN_FACTOR =
    LOCAL_AMOUNT = P_STAB_RAST1
    LOCAL_FACTOR =
    EXCHANGE_RATEX =
    FIXED_RATE =
    DERIVED_RATE_TYPE =
    EXCEPTIONS
    NO_RATE_FOUND = 1
    OVERFLOW = 2
    NO_FACTORS_FOUND = 3
    NO_SPREAD_FOUND = 4
    DERIVED_2_TIMES = 5
    OTHERS = 6 .
    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. " convert_values

    solved

  • How to print deposit number in top margin and reset pagination eavh change

    I am using Report Builder 6.0.8.27.0 against a version 10 database
    I have a built a report that works properly. It consists of about 1800 mineral deposits with one main frame cycling on the mineral deposit number and the frame contains a whole bunch of repeating frames containing detail information. Each mineral deposit may be one and 20+ pages long. The report works properly but I need to make the following additions..
    1) At present, the mineral deposit number is only displayed on the first page of the report 'segment'. What I would like to do is have the deposit number displayed in the top margin on each page, next to the title but I am not sure how to do this.
    I began by creating a field in the top margin, but when I change the Source of the Field (in the property palette) to the deposit number (a database field) I get the following error:
    REP-1213: Field 'F-1' references column MDD_NO at a frequency below its group. This is obviously because this is in the margin and the deposit number occurs within the main repeating frame.
    Any suggestions how I might do this - I'm afraid I'm not terribly familiar with reports - and don't have any good reference material at my fingertips. (Only the help files and digging through them is painful - especially when one is not sure what one is looking for.)
    Any help woule be appreciated.
    2) I would also like to create a special page number/sequence where each deposit would have it's own set of pagination
    ie.: Deposit-001 page 1
    Deposit-001 page 2
    etc
    and then reset when the deposit number changes
    Deposit-002 page 1
    Deposit-002 page 2
    Basically, the idea is to restart pagination at each change in deposit number and change the deposit number to the current one. Again, I don't know how to do this.
    The report will appear as a large pdf - which I know has it's own pagination. The reason I want the Deposit number and it's page sequence to appear in the top margin is to make it easier for the client to identify which pages belong to which deposit when they print out and work with 4 or 5 different deposits sets at the same time.
    I realize I can achieve this by printing one pdf for each deposit, but 1800 individual pdf's is a bit much. to handle.
    Thanks for whatever help you can give me
    Glenn

    Hi, 
             just populate ur eventcat  like this , may be this can help u
    form zf_eventcat  using    p_it_eventcat type slis_t_event.
      data l_eventcat type slis_alv_event.
      clear l_eventcat.
    *Get all the events.
      call function 'REUSE_ALV_EVENTS_GET'
        exporting
          i_list_type     = 0
        importing
          et_events       = p_it_eventcat
        exceptions
          list_type_wrong = 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.
    TOP-OF-PAGE FORM
      clear l_eventcat.
      read table p_it_eventcat into l_eventcat with key
                              name = slis_ev_top_of_page.
      if sy-subrc = 0.
        move 'ZF_TOP_OF_PAGE' to l_eventcat-form.
        modify p_it_eventcat from l_eventcat index sy-tabix
                                             transporting form.
      endif.
    PF_STATUS_SET FORM
      clear l_eventcat.
      read table p_it_eventcat into l_eventcat with key
                              name = slis_ev_pf_status_set.
      if sy-subrc = 0.
        move 'ZF_PF_STATUS_SET' to l_eventcat-form.
        modify p_it_eventcat from l_eventcat index sy-tabix
                                          transporting form.
      endif.
    USER_COMMAND FORM
      clear l_eventcat.
      read table p_it_eventcat into  l_eventcat with key
                               name = slis_ev_user_command.
      if sy-subrc = 0.
        move 'ZF_USER_COMMAND' to  l_eventcat-form.
        modify p_it_eventcat from l_eventcat index sy-tabix
                                          transporting form.
      endif.
    endform.                    " zf_eventcat
    reward if helpful

Maybe you are looking for