Total qty field in OACT and PCH1 tables

Hi,
What field in the OACT and PCH1 tables will give me a total quantity of pieces on the a/p invoice or purchase order, respectively?
Thanks,
Shelby

Hi
Are you trying add the fields that are present in Suda query.?
You can just use Ctrl Click on the colum and it gives you a total .
Otherwise ,try this
you need to add field and same to group if you are using sum
SELECT T1.DocNum AS 'Document Number',T1.CardName , T1.DocDate,T1.Comments,SUM(T1.TotalExpns) AS 'Total Freight Charges',
SUM(T0.Quantity) AS 'Quantity'
FROM  [dbo].[PCH1] T0  INNER  JOIN [dbo].[OPCH] T1  ON  T1.[DocEntry] = T0.DocEntry
WHERE T1.DocType = 'I'
GROUP By T1.DocNum,T1.Cardname,T1.DocDate,T1.Comments
Hope this help
bishal
Edited by: Bishal Adhikari on Mar 6, 2009 1:21 PM

Similar Messages

  • User exit to change total qty field in co01

    Dear Friends ,
    i need to increase  total qty field by 5 in co01 transaction in general tab  . which exit or badi should be used to accomplish the task .
    Thanks
    Amit Ranjan

    Hi,
    try from these exits-----
                                                                                    Exit Name           Description                                                                               
    CCOWB001            Customer exit for modifying menu entries                     
    COIB0001            Customer Exit for As-Built Assignment Tool                   
    COZF0001            Change purchase req. for externally processed operation      
    COZF0002            Change purchase req. for externally procured component       
    PPCO0001            Application development: PP orders                           
    PPCO0002            Check exit for setting delete mark / deletion indicator      
    PPCO0003            Check exit for order changes from sales order                
    PPCO0004            Sort and processing exit: Mass processing orders             
    PPCO0005            Storage location/backflushing when order is created          
    PPCO0006            Enhancement to specify defaults for fields in order header   
    PPCO0007            Exit when saving production order                            
    PPCO0008            Enhancement in the adding and changing of components         
    PPCO0009            Enhancement in goods movements for prod. process order       
    PPCO0010            Enhancement in make-to-order production - Unit of measure    
    PPCO0012            Production Order: Display/Change Order Header Data           
    PPCO0013            Change priorities of selection crit. for batch determination 
    PPCO0015            Additional check for document links from BOMs                
    PPCO0016            Additional check for document links from master data         
    PPCO0017            Additional check for online processing of document links     
    PPCO0018            Check for changes to production order header                 
    PPCO0019            Checks for changes to order operations                       
    PPCO0021            Release Control for Automatic Batch Determination            
    PPCO0022            Determination of Production Memo                             
    PPCO0023            Checks Changes to Order Components                           
    STATTEXT            Modification exit for formatting status text lines           
    regards,
    Prashant

  • How to set standart fields in SHIPPING and SALES tables in items?

    Hello SDN!
    I need to fill some standart fields in CT_SHIPPING and CT_SALES tables (sorry, I don't know their real names, written names used commonly in BADI) for items. I've got a BADI for header (extends IF_EX_CRM_ISA_BASKET_HEAD) and item (extends IF_EX_CRM_ISA_BASKET_ITEM) with methods CHANGEHEAD_BEFORE_ORDER and CHANGEITEMS_BEFORE_ORDER correspondenly. In these methods I try to fill required fields. These fields filled OK for header, but when I tried to fill fields for item it still saved to header. In these tables REF_KIND sets 'B' for item, REF_GUID also sets properly... Can anybody give rules for filling these fields? What main fields (such as REF_KIND) must be set and which values must they have?
    version of subject is CRM 5.0 SP 11
    Help will be appreciated.
    Regards, Lev
    Edited by: Lev Kulaev on Sep 8, 2008 9:24 AM
    give a version of CRM and give more detailed description of problem

    Hello Lev,
    Yes, if you have a "fully loaded" order - I mean some good order that has all the business data (such as shipping, sales ord, schedline etc. available. Usually an order that has been created in CRM or downloaded from R/3 should do to understand the data structures.
    To start with, just give the Transaction Number as the onl;y input and execute. And read through the output - each set (ET_SHIPPING) etc you are interested in. The several GUID and REF_GUID and REF_KINDs can be better understood with an example than me providing the explanation and code.
    An equivalent counterpart to this report program is the CRM_ORDER_READ, which does the same thing but does not let you play with the maintain part. CRM_ORDER_MAINTAIN program allows you to try the ipdate / change / maintain.
    Well here is the help text  for CRM_ORDER_MAINTAIN
    <h5>Short text</h5>
    Test program for function module CRM_ORDER_MAINTAIN
    <h5>Purpose</h5>
    This program replaces the missing option to execute a single test for the function module CRM_ORDER_MAINTAIN.
    The usual single test function in transaction SE37 is not possible as sorted tables are used as import parameters. The module RS_COMPLEX_OBJECT_EDIT used from Basis for maintaining import parameters is only able to process standard tables.
    <h5>Features</h5>
    The report executes a test call of the function module CRM_ORDER_MAINTAIN and displays the result (the export parameters).
    In addition, it is possible to
    <li>Save the changed data on the database,
    <li>Delete the buffer afterwards,
    <li>And, by calling CRM_ORDER_READ, to read it again.
    <h5>Selection</h5>
    <li>Specify the transaction number, the transaction GUID or the item GUID for changing an existing transaction.
    <li>Specify how many headers or items are to be created for creating new transactions or items.
    <li>Select "Subobject to be maintained" for the subobjects that you wish to change or enter.
    <li>After, enter "Maintain input values", and maintain the interface for CRM_ORDER_MAINTAIN. This means you make an entery for the IT_X_COM parameter for subobject X, and make the required entries in the CT_INPUT_FIELDS table.
    <li>If you wish to save and initialize after the change, specify this.
    <li>If the transaction should be re-read in the buffer afterwards, specify this.
    <h5>Standard Variants</h5>
    You can save your entries as a variant. All entered data is then stored under a GUID in the INDX table, and can be recovered again by calling this variant.
    <h5>Output</h5>
    The output parameter for CRM_ORDER_MAINTAIN and, if necessary, for CRM_ORDER_SAVE, CRM_ORDER_INITIALIZE and CRM_ORDER_READ are issued.
    Easwar Ram
    http://www.parxlns.com

  • DIFF: Field string ,Structure and Internal table declaration

    Hai,
           what is the diference between  Field string ,Structure in ABAP program and Internal table declaration and how it will work ?
    Thank you
    ASHOK KUMAR.

    hi,
    Look this u will get a good idea.
    *& Report  ZTYPES                                                      *
    REPORT  ZTYPES                                                  .
    * Table declaration (old method)
    DATA: BEGIN OF tab_ekpo OCCURS 0,             "itab with header line
      ebeln TYPE ekpo-ebeln,
      ebelp TYPE ekpo-ebelp,
    END OF tab_ekpo.
    *Table declaration (new method)     "USE THIS WAY!!!
    TYPES: BEGIN OF t_ekpo,
      ebeln TYPE ekpo-ebeln,
      ebelp TYPE ekpo-ebelp,
    END OF t_ekpo.
    DATA: it_ekpo TYPE STANDARD TABLE OF t_ekpo INITIAL SIZE 0,      "itab
          wa_ekpo TYPE t_ekpo.                    "work area (header line)
    * Build internal table and work area from existing internal table
    DATA: it_datatab LIKE tab_ekpo OCCURS 0,      "old method
          wa_datatab LIKE LINE OF tab_ekpo.
    * Build internal table and work area from existing internal table,
    * adding additional fields
    TYPES: BEGIN OF t_repdata.
            INCLUDE STRUCTURE tab_ekpo.  "could include EKKO table itself!!
    TYPES: bukrs  TYPE ekpo-werks,
           bstyp  TYPE ekpo-bukrs.
    TYPES: END OF t_repdata.
    DATA: it_repdata TYPE STANDARD TABLE OF t_repdata INITIAL SIZE 0,   "itab
          wa_repdata TYPE t_repdata.                 "work area (header line)
    Regards
    Reshma

  • Controlling Business transaction field in COSS and COSP table

    Hi all,
    I am trying to understand the idea of the field business transaction in tables COSS and COSP (where as much as I understood are the line items in CO - please corect me if I am wrong). It seems logically that this field is connected somehow to the SAP transactions. Do you know where is this connection and how can I see it?
    I need to know which SAP transactions will get business transaction COIN for example. If you have some documentaion or explanation of how this works, it will be very useful to me.
    Thank you,
    Maria

    Hi Maria,
    When you run settlement for internal orders using KO88, the records are saved into COSS table with the Business transaction KOAO.
    Just for your understanding the meaning of the main CO tables:
    - COEP: this is the CO document line items table (the one that is searched when you run, for example, KSB1 or KOB1 report transactions);
    - COSS: this is the CO cost totals table for internal postings, that is, the postings done into CO module that is going to reflect on the same CO module;
    - COSP: this is the CO cost totals table for external postings, that is, the postings done into any module that is going to reflect on CO module.
    To complete what it had been explained: COIN means the postings done from any module to CO.
    I hope it helps you.
    Best Regards,
    Daniel

  • Adding Custom Fields to BSEG and BKPF Tables

    Hi All,
    My customer would like to add around 5 fields to BKPF table and 6-7 fields to BSEG table. Can you all suggest me whether it would be a good idea to add any custom field to these tables ? I would like to mention that standard fields available in these tables will not be used for the requirements of the customer and he is insisting on adding custom fields. I need your expert advice on this matter.
    Regards,
    Rohit

    Hi Friend,
    Please do not add any custom fields in those tables.
    These two tables are pillar of accounting entries in SAP, if you want to push them then it is OK, otherwise find some other way.
    Regards
    Krishnendu

  • Order qty field in bapi and exit

    Hi All,
    Pls resolve my issue......
    I am creating the sales order through 'VA01' t-code.Now based on some conditions I will create a new sales order through BAPI_SALESDOCU_CREATEFROMDATA1 in t-code. I could not found the order quantity field in tables of BAPI thus I am not able to update the order quatity(kwmeng in vbap) for new sales order. Somebody suggested me that I need to update the schedule line item req_qty(its not working).
    *Second Issues:*++
    I am writing the code in SAVE DOCUMENT user exit , this is going into infinite loop. Can anybody suggest me the correct EXIT too.
    Points will be given
    Thanks in advance.

    Hi Friend,
    For the first point:
    Pass quantity in TARGET_QTY of ITEM parameter
    and REQ_QTY of SCHEDULE line parameter of the specified BAPI.
    It will solve ur problem.
    Please clarify little bit on second point.
    Regards
    Krishnendu

  • CJI3 report not displaying values correctly in the "Total Quantity" field

    Dear Friends,
    Need your assistance on the issue explained below,
    In our project there is a scenario where the actuals posted on a WBS are split/distributed to various WBS.These actuals that are split can be CATS entries,manual posting (KB21) or postings that come to R3 from a legacy system.The split happens by means of a custom program and is not standard.There is a tab seperated text file that contains the split percentages and the sender as well as the receiver WBS elements.Off late it has been observed that after the split is done the CJI3 report does not show the split quantities correctly and hence there is difference in the values displayed in the currency field.This is not a rounding off difference and is considerable.We have done all possible analysis from our side but i am unable to find how the difference occurs.
    To add to this i have even come across certain notes which describe the issue closely but none of it has helped so far. I have simulated the scenario with the same settings in the Quality server and it seems to work fine there without any glitches. We have even compared the program in both the Quality as well as the Production servers and there is no difference in the program as well.The values for the total quantity field are stored in the table COVP and it has been observed the report is fetching this data to display in CJI3.
    I have run CJEN too but this too does not correct the report. I was just wondering if any of our colleagues can provide me with some suggestions or insight in this issue.
    Regards,
    Gokul

    Hi Praveen,
    Thanks for the response.
    Actually i did debug the program with the help of our technical guys but found nothing wrong in both the quality and the production system. We compared the program in both the systems and it seems to be same. I am exploring this issue. Will update the findings here.
    In case anyone has any suggestion please do suggest.
    Regards,
    Gokul

  • OBJNR is blank at VBAK and VBAP tables

    Dear collegues,
    There´s a strange situation on customer´s system. When end-user create a new quotation, the OBJNR field at VBAK and VBAP tables doesn´t fill itself, it remains blank. I believed that the field was filled when the document was saved. What´s wrong?
    Regards, Otávio.

    Hi,
    This might  be due to many reasons.Please check if there any dumps related to it in ST22/SM21.
    Also check if there any enough dialog/bckg work process to process the job.
    filling up takes more time depending on the no of records in the application tables.
    regards
    Nagaraju

  • See the fields of RT and CRT

    How to see the fields of RT and CRT Tables?
    Eg: if i wanna see fields of PANNNN or any Z tables simply i can go SE11 there in Tables i will provide the table name.
    if i need to see the fileds of RT and CRT show me the procedure...

    Hi Vamsi,
    Go to the Abap editor and execute the report RPCLSTRX.
    U will get a screen where u have to enter a particular employee number ..
    Then u will get a list of payroll periods for that pernr.
    Now select any period and then you will find all the tables for that pernr..
    Now select the RT and CRT tables and see the corresponding details for that pernr for the particular table......
    Award points if the answer is useful for you...
    Let me know if you have any doubts .......
    Regards,
    Naveen.

  • Table Required for Delivered Qty field in Sales Order

    Hi friends
    I can see confirmed order qty, required qty, quantity committed  in VBEP table.
    But if you see in sales order Schedule Lines you'll see one more field named as
    Delivered Quantity.
    I am not able to find this Delivered Qty in any of the SD tables....
    pls help me to find this table and field
    Pts rewarded for helpful ans..
    Thanks and regards
    Snehal

    hi,
    delivery related data is stored in LIKP and LIPS tables
    related to sd.
    reward points if hlpful.

  • SSRS 2008 have 2 colums with amount needs to add Total cost and than total cost column divide by Total qty get avg

    SSRS 2008,  have this report
     Qty Column --------- Est cost column -----    Mark up Cost Column  -   Did add Total cost column
    4 pcs-                       $ 2000.00  --------------$  50.00 --------------- $ 2050.00
    Avg  Cost                                                                                      
    $2050/4=  512.50
    how to write this exp to get value $ 512.50 
    what I did , its not giving me correct result,
    =Sum(Fields!estCOSTAMOUNT.Value+Fields!COSTMARKUP.Value)/(Fields!QTY.Value)
    can some one please advise what I am doing wrong.
    thanks in advance

    I tried both exp, did not work
    may be I was not  clear in the question
    Qty Column --------- Est cost column -----    Mark up Cost Column  -   Did add Total cost column
    4 pcs-                       $ 2000.00  --------------$  50.00 --------------- $ 2050.00
    2 pcs ------------------$ 1500.00  --------------=$100.00 ----------------$1600.00
    Total   qty  6  pcs-----$ 3500.00------------------$150.00---------------$ 3650.00
    Avg  Cost                                                                                      
    $3650..00/6=  608.33
    my field name
    =Sum(Fields!COSTAMOUNT.Value)  +  want to add cost amount and Mark up and divide with qty total
    =Sum(Fields!COSTMARKUP.Value)
    =Sum(Fields!QTY.Value)
    please help how can I write it to get the result

  • Qty field addtion based on item no. for ekbe table

    Hi experts,
                      below is my code..
    LOOP AT IT_EKKO.
      READ TABLE IT_LFA1 WITH KEY LIFNR = IT_EKKO-LIFNR.
       MOVE: IT_LFA1-NAME1 TO IT_DISPLAY-NAME1.
       MOVE: IT_EKKO-LIFNR TO IT_DISPLAY-LIFNR,
             IT_EKKO-AEDAT TO IT_DISPLAY-AEDAT,
             IT_EKKO-ERNAM TO IT_DISPLAY-ERNAM,
             IT_EKKO-EKGRP TO IT_DISPLAY-EKGRP.
    READ TABLE IT_EKPO WITH KEY EBELN = IT_EKKO-EBELN.
       MOVE: IT_EKPO-EBELN TO IT_DISPLAY-EBELN,
             IT_EKPO-MATNR TO IT_DISPLAY-MATNR,
             IT_EKPO-MENGE TO IT_DISPLAY-MENGE.
             LOOP AT IT_EKBE where ebeln eq it_ekko-ebeln.
                loop at it_ekbe." WHERE ebelp eq it_ekbe-ebelp.
             IT_DISPLAY-QTY = IT_DISPLAY-QTY + IT_EKBE-MENGE.
             AT END OF EBELP.
            APPEND IT_DISPLAY.
             CONTINUE.
             ENDAT.
             ENDLOOP.
             endloop.
             APPEND IT_DISPLAY.
             CLEAR IT_EKKO.
             ENDLOOP.
    my requirement is to display lifnr,ernam,ekgrp.....etc....
    but the condition is in ekbe table i hav to take purachse document no. from ekko table..based on this ebeln if suppose
    the item no. ebelp in ekbe has value say 10,10, den 20,20..for a single ebeln...then for same item no(10). the qty field should be added
    and for (20) item no. the qty field should be added.
    plz help...
    hw can i acheive this requirement.
    thanks n regards,
    Ashmita Singh.

    Hi Ashmita,
    Do the following changes in your program.
    Define it_lfa1 table as Hashed table with unique key on lifnr.
    Sort table it_ekpo before the loop start on ebeln and used binary search to read data from table.
    Define it_ekbe as sorted table with non-unique key on ebeln and EBELP use single loop.
    Write the following statement before main loop start. (ie it_ekko)
    delete ADJACENT DUPLICATES FROM it_ekbe COMPARING eblen EBELP.
    LOOP AT it_ekko.
    * Define it_lfa1 table as Hashed table with unique key
      READ TABLE it_lfa1 WITH KEY lifnr = it_ekko-lifnr.
      MOVE: it_lfa1-name1 TO it_display-name1.
      MOVE: it_ekko-lifnr TO it_display-lifnr,
      it_ekko-aedat TO it_display-aedat,
      it_ekko-ernam TO it_display-ernam,
      it_ekko-ekgrp TO it_display-ekgrp.
    * Sort table it_ekpo on ebeln and used binary search
      READ TABLE it_ekpo WITH KEY ebeln = it_ekko-ebeln.
      MOVE: it_ekpo-ebeln TO it_display-ebeln,
      it_ekpo-matnr TO it_display-matnr,
      it_ekpo-menge TO it_display-menge.
    * Define it_ekbe as sorted table with non unique key on ebeln and use single loop.
      LOOP AT it_ekbe WHERE ebeln EQ it_ekko-ebeln.
          it_display-qty = it_display-qty + it_ekbe-menge.
      ENDLOOP.
      APPEND it_display.
      CLEAR it_ekko.
    ENDLOOP.
    Kind Rgds
    Ravi Lanjewar

  • With holding tax report with material and qty fields

    Dear All,
    Is there any standard report available with with holding tax data with material and qty fields.
    Thanks,
    Sekhar.

    dear Friend,
    Withholding tax will deduct on services. Hence Material and quantity is not relavent.
    There is no report is available also.
    reg
    Madhu M

  • Download the KTOPL  field data and GLT0 table data into one Internal table

    Hi,
    I have downloaded GLT0 table fields  data to PC file . But i need to download KTOPL(Chart Of Accounts) data also. in GLT0 table there is no KTOPL field.
    But in SKA1 table have KTOPL field. Then what is the issue is GLT0 data & KTOPL field data needs to download into one Internal Table.
    anybody could you please solve this problem. immediately need to solve this.
    Below is the code.
    REPORT ZFXXEABL_1 NO STANDARD PAGE HEADING
                    LINE-SIZE 200.
    Tables Declaration
    TABLES : GLT0.
    Data Declaration
    DATA :   FP(8)           TYPE C,
             YEAR           LIKE GLT0-RYEAR,
             PERIOD(3)       TYPE C,
             DBALANCE         LIKE VBAP-NETWR VALUE 0 ,
             CBALANCE         LIKE VBAP-NETWR VALUE 0.
    *Internal table for for final data..
    DATA : BEGIN OF REC1 OCCURS 0,
           BAL             LIKE GLT0-TSLVT value 0,
           COAREA          LIKE GLT0-RBUSA,
          CA(4)           TYPE C,
           KTOPL           LIKE ska1-ktopl, 
           CCODE           LIKE GLT0-BUKRS,
           CREDIT          LIKE  VBAP-NETWR,
           CURRENCY        LIKE GLT0-RTCUR,
           CURTYPE(2)      TYPE N,
           DEBIT           LIKE VBAP-NETWR,
           YEAR(8)         TYPE C,
           FY(2)           TYPE C,
           ACCOUNT         LIKE GLT0-RACCT,
           VER             LIKE GLT0-RVERS,
           VTYPE(2)        TYPE N,
           CLNT            LIKE SY-MANDT,
           S_SYS(3)        TYPE C,
           INDICATOR      LIKE GLT0-DRCRK,
           END OF REC1.
    DATA : C(2) TYPE N,
           D(2) TYPE N.
    DATA REC1_H LIKE REC1.
    Variable declarations
    DATA :
           W_FILES(4) TYPE N,
           W_DEBIT LIKE GLT0-TSLVT,
           W_CREDIT LIKE GLT0-TSLVT,
           W_PCFILE LIKE RLGRAP-FILENAME ,
           W_UNIXFILE LIKE RLGRAP-FILENAME,
           W_PCFILE1 LIKE RLGRAP-FILENAME,
           W_UNIXFIL1 LIKE RLGRAP-FILENAME,
           W_EXT(3) TYPE C,
           W_UEXT(3) TYPE C,
           W_PATH LIKE RLGRAP-FILENAME,
           W_UPATH LIKE RLGRAP-FILENAME,
           W_FIRST(1) TYPE C VALUE 'Y',
           W_CFIRST(1) TYPE C VALUE 'Y',
           W_PCFIL LIKE RLGRAP-FILENAME.
    DATA: "REC LIKE GLT0 OCCURS 0 WITH HEADER LINE,
          T_TEMP LIKE GLT0 OCCURS 0 WITH HEADER LINE.
    DATA: BEGIN OF REC3 OCCURS 0.
          INCLUDE STRUCTURE GLT0.
    DATA: KTOPL LIKE SKA1-KTOPL,
          END OF REC3.
    DATA: BEGIN OF T_KTOPL OCCURS 0,
          KTOPL LIKE SKA1-KTOPL,
          SAKNR LIKE SKA1-SAKNR,
          END OF T_KTOPL.
    Download data.
    DATA: BEGIN OF I_REC2 OCCURS 0,
           BAL(17),        "             like GLT0-TSLVT value 0,
           COAREA(4),      "          like glt0-rbusa,
           CA(4),          "  chart of accounts
           CCODE(4),       "           like glt0-bukrs,
           CREDIT(17),     "          like  vbap-netwr,
           CURRENCY(5),    "       like glt0-rtcur,
           CURTYPE(2),     "      type n,
           DEBIT(17),      "           like vbap-netwr,
           YEAR(8),        "  type c,
           FY(2),          " type c, fiscal yr variant
           ACCOUNT(10),    " like glt0-racct,
           VER(3),         "    like glt0-rvers,
           VTYPE(3),       " type n,
           CLNT(3),        "like sy-mandt,
           S_SYS(3),       "like sy-sysid,
           INDICATOR(1),   "   like glt0-drcrk,
          END OF I_REC2.
    Selection screen.                                                    *
    SELECTION-SCREEN BEGIN OF BLOCK BL1  WITH FRAME TITLE TEXT-BL1.
    SELECT-OPTIONS : COMPCODE FOR GLT0-BUKRS,
                      GLACC FOR GLT0-RACCT,
                      FISYEAR   FOR GLT0-RYEAR,
                    no intervals no-extension,      "- BG6661-070212
                       FISCPER FOR GLT0-RPMAX,
                     busarea   for glt0-rbusa,
                      CURRENCY  FOR GLT0-RTCUR.
    SELECTION-SCREEN END   OF BLOCK BL1.
    SELECTION-SCREEN BEGIN OF BLOCK BL2  WITH FRAME TITLE TEXT-BL2.
    PARAMETERS:
      P_UNIX AS CHECKBOX,                  "Check box for Unix Option
      P_UNFIL LIKE RLGRAP-FILENAME,        " Unix file Dnload file name
       default '/var/opt/arch/extract/GLT0.ASC',  "- BG6661-070212
      P_PCFILE AS CHECKBOX,                "Check box for Local PC download.
      P_PCFIL LIKE RLGRAP-FILENAME         " PC file Dnload file name
                 default 'C:\GLT0.ASC'.           "- BG6661-070212
          DEFAULT 'C:\glt0_gl_balance_all.asc'.     "+ BG6661-070212
    SELECTION-SCREEN END   OF BLOCK BL2.
    *eject
    Initialization.                                                     *
    INITIALIZATION.
    Try to default download filename
    p_pcfil = c_pcfile.
    p_unfil = c_unixfile.
    if sy-sysid eq c_n01.
       p_unfil =   c_unixfile.
    endif.
    if sy-sysid eq c_g21.
       p_unfil =   c_g21_unixfile.
    endif.
    if sy-sysid eq c_g9d.
       p_unfil =   c_g9d_unixfile.
    endif.
    Default for download filename
    *{ Begin of BG6661-070212
      CONCATENATE C_UNIXFILE
                  SY-SYSID C_FSLASH C_CHRON C_FILENAME INTO P_UNFIL.
    *} End of BG6661-070212
    AT SELECTION-SCREEN OUTPUT.
    loop at screen.
       if screen-name = 'P_PCFIL'.        "PC FILE
         screen-input = '0'.
         modify screen.
       endif.
       if screen-name = 'P_UNFIL'.        "UN FILE
         screen-input = '0'.
         modify screen.
       endif.
    endloop.
      if w_first = 'Y'.
        perform path_file.
        w_first = 'N'.
      endif.
    if w_cfirst = 'Y'.
       perform cpath_file.
       w_cfirst = 'N'.
    endif.
    Start-of-Selection.                                                 *
    START-OF-SELECTION.
    *COLLECT DATA
      PERFORM COLLECT_DATA.
    *BUILD FILENAMES
      PERFORM BUILD_FILES.
    *LOCAL
      IF P_PCFILE = C_YES.
       PERFORM LOCAL_DOWNLOAD.
      ENDIF.
    *UNIX
      IF P_UNIX = C_YES.
        PERFORM UNIX_DOWNLOAD.
      ENDIF.
      IF P_PCFILE IS INITIAL AND P_UNIX IS INITIAL.
        MESSAGE I000(ZL) WITH 'Down load flags both are unchecked'.
      ENDIF.
    END-OF-SELECTION.
    IF P_PCFILE = C_YES.
    WRITE :/ 'PC File'  , C_UNDER, P_PCFIL.
    ENDIF.
    *&      Form  DOWNLOAD
          Download                                                       *
    FORM DOWNLOAD.
      P_PCFIL =  W_PATH.
      DATA LIN TYPE I.
      DESCRIBE TABLE I_REC2 LINES LIN.
      WRITE:/ 'No of Records downloaded = ',LIN.
      CALL FUNCTION 'WS_DOWNLOAD'
           EXPORTING
               FILENAME            =  P_PCFIL
               FILETYPE            =  C_ASC   "c_dat   "dat
           TABLES
                DATA_TAB            = I_REC2  " t_str
               fieldnames          = t_strhd
           EXCEPTIONS
                FILE_OPEN_ERROR     = 1
                FILE_WRITE_ERROR    = 2
                INVALID_FILESIZE    = 3
                INVALID_TABLE_WIDTH = 4
                INVALID_TYPE        = 5
                NO_BATCH            = 6
                UNKNOWN_ERROR       = 7
                OTHERS              = 8.
      IF SY-SUBRC EQ 0.
      ENDIF.
    ENDFORM.
    *&      Form  WRITE_TO_SERVER
          text                                                           *
    -->  p1        text
    <--  p2        text
    FORM WRITE_TO_SERVER.
      DATA : L_MSG(100) TYPE C,
             L_LINE(5000) TYPE C.
      P_UNFIL =  W_UPATH.
      DATA LIN TYPE I.                           
      DESCRIBE TABLE I_REC2 LINES LIN.           
      WRITE:/ 'No of Records downloaded = ',LIN. 
      OPEN DATASET P_UNFIL FOR OUTPUT IN TEXT MODE.        " message l_msg.
      IF SY-SUBRC <> 0.
        WRITE: / L_MSG.
      ENDIF.
    perform header_text1.
      LOOP AT I_REC2.
        TRANSFER I_REC2 TO P_UNFIL.
      ENDLOOP.
      CLOSE DATASET P_UNFIL.
      WRITE : / C_TEXT , W_UPATH.
      SPLIT W_UNIXFILE AT C_DOT INTO W_UNIXFIL1 W_UEXT.
      CLEAR W_UPATH.
      IF NOT W_UEXT IS INITIAL.
        CONCATENATE W_UNIXFIL1  C_DOT W_UEXT INTO W_UPATH.
      ELSE.
        W_UEXT = C_ASC. " c_csv.
        CONCATENATE W_UNIXFIL1 C_DOT W_UEXT INTO W_UPATH.
      ENDIF.
    ENDFORM.                               " WRITE_TO_SERVER
    *&      Form  BUILD_FILES
    FORM BUILD_FILES.
      IF P_PCFILE = C_YES.
        W_PCFILE = P_PCFIL.
    ***Split path at dot**
        SPLIT W_PCFILE AT C_DOT INTO W_PCFILE1 W_EXT.
        IF NOT W_EXT IS INITIAL.
          CONCATENATE W_PCFILE1 C_DOT W_EXT INTO W_PATH.
        ELSE.
          W_PATH = W_PCFILE1.
        ENDIF.
      ENDIF.
      IF P_UNIX = C_YES.
        W_UNIXFILE = P_UNFIL.
        SPLIT W_UNIXFILE AT C_DOT INTO W_UNIXFIL1 W_UEXT.
        IF NOT W_UEXT IS INITIAL.
          CONCATENATE W_UNIXFIL1  C_DOT W_UEXT INTO W_UPATH.
        ELSE.
          W_UPATH = W_UNIXFIL1.
        ENDIF.
      ENDIF.
    ENDFORM.
    FORM CPATH_FILE.
    CLEAR P_PCFIL.
       CONCATENATE C_PCFILE
                   C_COMFILE SY-SYSID C_UNDER SY-DATUM SY-UZEIT
                   C_DOT C_ASC INTO  P_PCFIL.
    ENDFORM.                    " CPATH_FILE
    FORM PATH_FILE.
    CLEAR P_UNFIL.
      if sy-sysid eq c_n01.
       CONCATENATE C_UNIXFILE
                   C_COMFILE SY-SYSID C_UNDER SY-DATUM SY-UZEIT
                    C_DOT C_ASC INTO  P_UNFIL.
      endif.
      if sy-sysid eq c_g21.
      concatenate c_g21_unixfile
                  c_comfile sy-sysid c_under sy-datum sy-uzeit
                   c_dot c_asc into  p_unfil.
      endif.
      if sy-sysid eq c_g9d.
      concatenate c_g9d_unixfile
                  c_comfile sy-sysid c_under sy-datum sy-uzeit
                   c_dot c_asc into  p_unfil.
      endif.
    ENDFORM.                    " PATH_FILE
    Local_Download                                                       *
          Local                                                          *
    FORM LOCAL_DOWNLOAD.
    perform header_text.
    LOOP AT REC1.
    REC1-CLNT = SY-MANDT.
    REC1-S_SYS = SY-SYSID.
    MOVE:  REC1-BAL TO I_REC2-BAL,
            REC1-COAREA TO I_REC2-COAREA,
           REC1-CA TO I_REC2-CA,         
            REC1-KTOPL TO I_REC2-CA,       
            REC1-CCODE TO I_REC2-CCODE,
            REC1-CREDIT TO I_REC2-CREDIT,
            REC1-CURRENCY TO I_REC2-CURRENCY,
            REC1-CURTYPE TO I_REC2-CURTYPE,
            REC1-DEBIT TO I_REC2-DEBIT,
            REC1-YEAR TO I_REC2-YEAR,
            REC1-FY TO I_REC2-FY,
            REC1-ACCOUNT TO I_REC2-ACCOUNT,
            REC1-VER TO I_REC2-VER,
            REC1-VTYPE TO I_REC2-VTYPE,
            REC1-CLNT TO I_REC2-CLNT,
            REC1-S_SYS TO I_REC2-S_SYS,
            REC1-INDICATOR TO I_REC2-INDICATOR.
    APPEND I_REC2.
    CLEAR  I_REC2.
    ENDLOOP.
      IF NOT I_REC2[] IS INITIAL.
        PERFORM DOWNLOAD .
        CLEAR I_REC2.
        REFRESH I_REC2.
       ELSE.
       WRITE : / ' no record exist due to unavailability of data'.
      ENDIF.
    ENDFORM.                               " LOCAL_DOWNLOAD
    *&      Form  UNIX_DOWNLOAD
    FORM UNIX_DOWNLOAD.
    LOOP AT REC1.
    REC1-CLNT = SY-MANDT.
    REC1-S_SYS = SY-SYSID.
    MOVE:  REC1-BAL TO I_REC2-BAL,
            REC1-COAREA TO I_REC2-COAREA,
          REC1-CA TO I_REC2-CA,         
            REC1-KTOPL TO I_REC2-CA,       
            REC1-CCODE TO I_REC2-CCODE,
            REC1-CREDIT TO I_REC2-CREDIT,
            REC1-CURRENCY TO I_REC2-CURRENCY,
            REC1-CURTYPE TO I_REC2-CURTYPE,
            REC1-DEBIT TO I_REC2-DEBIT,
            REC1-YEAR TO I_REC2-YEAR,
            REC1-FY TO I_REC2-FY,
            REC1-ACCOUNT TO I_REC2-ACCOUNT,
            REC1-VER TO I_REC2-VER,
            REC1-VTYPE TO I_REC2-VTYPE,
            SY-MANDT TO I_REC2-CLNT,
            SY-SYSID TO I_REC2-S_SYS,
            REC1-INDICATOR TO I_REC2-INDICATOR.
    APPEND I_REC2.
    CLEAR  I_REC2.
    ENDLOOP.
      IF NOT I_REC2[] IS INITIAL.
        PERFORM WRITE_TO_SERVER.
        CLEAR I_REC2.
        REFRESH I_REC2.
      ELSE.
       WRITE : / ' no record exist due to unavailability of data'.
      ENDIF.
    ENDFORM.                               " UNIX_DOWNLOAD
    *&      Form  HEADER_TEXT
          text                                                           *
    -->  p1        text
    <--  p2        text
    *form header_text.
      concatenate c_bal c_ba c_ca c_cc  c_credit c_currency c_curtype
         c_debit c_fisyear c_fisvar c_acct c_ver c_vtype c_indicator
               into t_strhd
               separated by c_comma.
      append t_strhd.
    *endform.                               " HEADER_TEXT
    *&      Form  HEADER_TEXT1
          text                                                           *
    *form header_text1.
      concatenate c_bal c_ba c_ca c_cc  c_credit c_currency c_curtype
        c_debit c_fisyear c_fisvar c_acct c_ver c_vtype c_indicator
               into t_strhd1
               separated by c_comma.
      append t_strhd1.
      transfer t_strhd1 to p_unfil.
    *endform.                    " HEADER_TEXT1
    *&      Form  COLLECT_DATA
          Collect Data                                                   *
    FORM COLLECT_DATA.
    SELECT * FROM GLT0 INTO  TABLE REC3
                        WHERE   BUKRS IN COMPCODE
                        AND     RYEAR IN FISYEAR
                        AND     RPMAX IN FISCPER
                        AND     RACCT IN GLACC
                        AND     RTCUR IN  CURRENCY.
    SELECT KTOPL FROM SKA1
                 INTO TABLE T_KTOPL
                 FOR ALL ENTRIES IN REC3
                 WHERE SAKNR = REC3-RACCT.
    LOOP AT REC3 .
       select *
       from glt0
       into table t_temp
       where rldnr = rec-rldnr
         and rrcty  = rec-rrcty
          and rvers  = rec-rvers
         and bukrs = rec-bukrs
         and ryear = rec-ryear
          and racct  = rec-racct
           and rbusa  = rec-rbusa
           and rtcur <> 'ZAR'
         and rpmax  = rec-rpmax.
    if sy-subrc = 0.
            rec1-bal = '0.00'.
    else.
      rec1-bal = rec-hslvt.
      endif.
    *READ TABLE T_KTOPL WITH KEY SAKNR = REC-RACCT BINARY SEARCH.
    MOVE T_KTOPL-KTOPL TO REC3-KTOPL.
    CLEAR:  CBALANCE, DBALANCE.
    REC1-BAL = REC3-HSLVT.
    IF REC3-DRCRK = 'S'.
    IF REC3-HSLVT NE C_ZERO.
           YEAR   = REC-RYEAR.
           PERIOD = '000'.
           CONCATENATE PERIOD C_DOT YEAR INTO FP.
           REC1-INDICATOR = REC-DRCRK.
           REC1-DEBIT = C_ZERO.
           REC1-CREDIT = C_ZERO.
           REC1-CCODE = REC-BUKRS.
           REC1-YEAR  = FP.
           REC1-CURRENCY = REC-RTCUR.
           REC1-ACCOUNT  = REC-RACCT.
           rec1-bal      = rec-hslvt.
           dbalance = rec1-bal.
           REC1-CURTYPE = C_CTYPE.
           REC1-FY      = C_FY.
           REC1-COAREA   = REC-RBUSA.
           REC1-VER     = REC-RVERS.
           REC1-VTYPE   = C_CTYPE.
           REC1-CA      = C_CHART.
           APPEND REC1.
            C = 0.
          PERFORM D.
    ENDIF.
    IF REC3-HSL01 NE C_ZERO.
            YEAR   = REC3-RYEAR.
            PERIOD = '001'.
            CONCATENATE PERIOD C_DOT YEAR INTO FP.
            REC1-INDICATOR = REC3-DRCRK.
            REC1-DEBIT = REC3-HSL01 .
            REC1-CCODE = REC3-BUKRS.
            REC1-YEAR  = FP.
            REC1-CURRENCY = REC3-RTCUR.
            REC1-ACCOUNT  = REC3-RACCT.
           rec1-bal      = REC3-hsl01 + dbalance.
           dbalance = rec1-bal.
            REC1-CURTYPE = C_CTYPE.
            REC1-FY      = C_FY.
            REC1-COAREA   = REC3-RBUSA.
            REC1-VER     = REC3-RVERS.
            REC1-VTYPE   = C_CTYPE.
          REC1-CA      = C_CHART. 
            REC1-KTOPL = REC3-KTOPL. 
            APPEND REC1.
            C = 1.
         PERFORM D.
    ENDIF.
    IF  REC3-HSL02 NE C_ZERO.
          REC1-DEBIT = REC3-HSL02.
       YEAR   = REC3-RYEAR.
       PERIOD = '002'.
      CONCATENATE PERIOD C_DOT YEAR INTO FP.
         REC1-INDICATOR = REC3-DRCRK.
       REC1-DEBIT = REC3-HSL02.
       REC1-CCODE = REC3-BUKRS.
       REC1-YEAR  = FP.
       REC1-CURRENCY = REC3-RTCUR.
       REC1-ACCOUNT  = REC3-RACCT.
      rec1-bal      = REC3-hsl02 + dbalance.
      dbalance = rec1-bal.
            REC1-CURTYPE = C_CTYPE.
            REC1-FY      = C_FY.
            REC1-COAREA   = REC3-RBUSA.
            REC1-VER     = REC3-RVERS.
            REC1-VTYPE   = C_CTYPE.
          REC1-CA      = C_CHART. "-BF7957-070503
            REC1-KTOPL = REC3-KTOPL.  "+BF7957-070503
       APPEND REC1.
       C = 2.
    PERFORM D.
    ENDIF.
    IF  REC3-HSL03 NE C_ZERO.
            YEAR   = REC3-RYEAR.
            PERIOD = '003'.
            CONCATENATE PERIOD C_DOT YEAR INTO FP.
               REC1-INDICATOR = REC3-DRCRK.
            REC1-DEBIT = REC3-HSL03.
            REC1-CCODE = REC3-BUKRS.
            REC1-YEAR  = FP.
            REC1-CURRENCY = REC3-RTCUR.
            REC1-ACCOUNT  = REC3-RACCT.
           rec1-bal      = REC3-hsl03 + dbalance .
           dbalance =  rec1-bal.
            REC1-CURTYPE = C_CTYPE.
            REC1-FY      = C_FY.
            REC1-COAREA   = REC3-RBUSA.
            REC1-VER     = REC3-RVERS.
            REC1-VTYPE   = C_CTYPE.
           REC1-CA      = C_CHART. "-BF7957-070503
             REC1-KTOPL = REC3-KTOPL. "+BF7957-070503
            APPEND REC1.
          C = 3.
    PERFORM D.
    ENDIF.
    IF  REC3-HSL04 NE C_ZERO.
           REC1-DEBIT = REC3-HSL04.
              YEAR   = REC3-RYEAR.
              PERIOD = '004'.
             CONCATENATE PERIOD C_DOT YEAR INTO FP.
                REC1-INDICATOR = REC3-DRCRK.
             REC1-DEBIT = REC3-HSL04.
              REC1-CCODE = REC3-BUKRS.
              REC1-YEAR  = FP.
              REC1-CURRENCY = REC3-RTCUR.
              REC1-ACCOUNT  = REC3-RACCT.
             rec1-bal      = REC3-hsl04 + dbalance .
            REC1-CURTYPE = C_CTYPE.
            REC1-FY      = C_FY.
            REC1-COAREA   = REC3-RBUSA.
            REC1-VER     = REC3-RVERS.
            REC1-VTYPE   = C_CTYPE.
          REC1-CA      = C_CHART.  "-BF7957-070503
            REC1-KTOPL = REC3-KTOPL.  "+BF7957-070503
            APPEND REC1.
             dbalance = rec1-bal.
              C = 4.
              PERFORM D.
    ENDIF.
    Thanks and Regards,
    Ram

    use logical database SDF, nodes ska1 and  skc1c
    A.

Maybe you are looking for

  • Faster split than String.split() and StringTokenizer?

    First I imrpoved performance of split by replacing the String.split() call with a custom method using StringTokenizer:                 final StringTokenizer st = new StringTokenizer(string, separator, true);                 String token = null;      

  • I shut down new update in middle-now I have nothing

    Well I got up this morning to an update that said it would take 10 mins.  So an hr later I still see it circling, I thought it was frozen.  I couldnt power down or anything, so I pulled battery. Apparently some update took place as the new home scree

  • Siebel Hangs up when changing the status of service request

    Hi, We are facing this typical problem since last 2 weeks. When closing the SR, CRM hangs for random(unable to detect a pattern till now) SRs. The steps we follow to an SR is: 1. Enter the SR # 2. Change the status to "resolved" 3. Type the resolutio

  • Bridge Not Working

    I'm going to try and make this as clear as possible because I'm not as smart as many of you so please bear with me. I'm working with Adobe Bridge CS6 5.0.2.4 on my Mac OS X 10.9.2. A couple days ago when I opened it, the following message popped up.

  • Database used in java card?

    what database is used in java card?Can we use Record management system or sqlite here?