Gurus...Need help....extract data from BKPF header table and BSEG line item

Gurus,
I have to write the logic to fetch data from bkpf and bseg. Need help on how can i do that..
I have to get bukrs  belnr gjahr ldgrp from BKPF for a given date and company code. For all these documents, then i have to get the line items from BSEG if the ldgrp is I1 or SPACE.
If the ldgrp is not I1 or SPACE then i have to fetch the records from BSEG_ADD and then generate a ALV report with all the data including the data that was fetched from BKPF.
So, it wil be a combined ALV report that displays header as well as LINE item data together...
Can u please help me with the code...I am not sure how can everything go all together in one internal table....Becoz once its there in one table then only a ALV list can be generated.......
Cheers:
Sam

hi Sam, this may be of some similar thing.
Use this program, I got this prog from a source and we added a small conditional check in the program which checks document numbers in BSEG and also comapres in BKPF and sees if the output from BSEG falls under the posting data range specified in the initial selection.
Now just so you know, this output is kinda messed up, so you will have to play with it in Excel to extract the document numbers, if that is what you want.
============================
PROGRAM....... ZFI_BSEG_DOWNLOAD
TITLE......... Download BSEG
PROGRAM TYPE.. Download
======================================================================
GENERAL DOCUMENTATION AND COMMENTS
<...>
======================================================================
ASSOCIATED PROGRAMS
<Program>..... <Description>
======================================================================
CHANGE HISTORY
Date By Ticket Description
REPORT zfi_bseg_download.
TABLES: bseg, bkpf.
TYPES: BEGIN OF ty_output,
line(6000) TYPE c,
END OF ty_output.
TYPES: ty_tab_output TYPE TABLE OF ty_output,
ty_tab_nametab TYPE TABLE OF x031l.
CONSTANTS: c_delimiter(04) TYPE c VALUE '"%%"',
c_records TYPE i VALUE 10000.
SELECTION-SCREEN
SELECT-OPTIONS: p_bukrs FOR bseg-bukrs,
p_belnr FOR bseg-belnr,
p_buzei FOR bseg-buzei,
p_gjahr FOR bseg-gjahr,
p_budat for bkpf-budat.
SELECTION-SCREEN SKIP.
PARAMETERS: p_file LIKE rlgrap-filename OBLIGATORY.
SELECTION-SCREEN SKIP.
PARAMETERS: p_append AS CHECKBOX DEFAULT 'X'.
START-OF-SELECTION
START-OF-SELECTION.
PERFORM get_records.
*& Form get_records
FORM get_records.
DATA: l_cursor TYPE cursor,
lt_bseg TYPE TABLE OF bseg,
ls_bseg LIKE LINE OF lt_bseg,
lt_output TYPE ty_tab_output,
ls_output LIKE LINE OF lt_output,
lt_nametab TYPE ty_tab_nametab,
ls_nametab LIKE LINE OF lt_nametab,
l_field(30) TYPE c,
l_output(50) TYPE c,
l_date(10) TYPE c,
l_len TYPE i.
FIELD-SYMBOLS: <field>.
IF p_append NE space.
OPEN DATASET p_file FOR APPENDING IN TEXT MODE.
ELSE.
OPEN DATASET p_file FOR OUTPUT IN TEXT MODE.
ENDIF.
Retrieve BSEF fieldnames and data types
PERFORM get_fields CHANGING lt_nametab.
OPEN CURSOR l_cursor FOR
SELECT * FROM bseg
WHERE bukrs IN p_bukrs
AND belnr IN p_belnr
AND buzei IN p_buzei
AND gjahr IN p_gjahr.
Write out fieldnames
IF p_append IS INITIAL.
LOOP AT lt_nametab INTO ls_nametab.
CONCATENATE ls_output ls_nametab-fieldname
INTO ls_output SEPARATED BY c_delimiter.
ENDLOOP.
IF ls_output+0(4) = c_delimiter.
SHIFT ls_output LEFT BY 4 PLACES.
ENDIF.
l_len = strlen( ls_output ).
TRANSFER ls_output TO p_file LENGTH l_len.
ENDIF.
Process BSEG records
DO.
CLEAR lt_bseg.
FETCH NEXT CURSOR l_cursor
INTO TABLE lt_bseg
PACKAGE SIZE c_records.
IF sy-subrc 0.
EXIT.
ENDIF.
LOOP AT lt_bseg INTO ls_bseg.
SELECT single * FROM BKPF
WHERE BUKRS = ls_bseg-BUKRS
AND BELNR = ls_bseg-BELNR
AND GJAHR = ls_bseg-GJAHR
AND BUDAT in p_budat.
if syst-subrc 0.
continue.
endif.
CLEAR ls_output.
Process individual fields of BSEG record
LOOP AT lt_nametab INTO ls_nametab.
CONCATENATE 'LS_BSEG-' ls_nametab-fieldname INTO l_field.
ASSIGN (l_field) TO <field>.
CLEAR l_output.
Process by field data types
CASE ls_nametab-exid.
WHEN 'C' OR 'N' OR 'I'.
Character, Numeric & Integer
l_output = <field>.
WHEN 'D'.
Dates
WRITE <field> TO l_date DD/MM/YYYY.
l_output = l_date.
WHEN 'P'.
Packed decimals
WRITE <field> TO l_output.
WHEN OTHERS.
MESSAGE a000(zs) WITH 'Data type error - ' ls_nametab-exid.
ENDCASE.
SHIFT l_output LEFT DELETING LEADING space.
CONCATENATE ls_output l_output
INTO ls_output SEPARATED BY c_delimiter.
ENDLOOP.
IF ls_output+0(4) = c_delimiter.
SHIFT ls_output LEFT BY 4 PLACES.
ENDIF.
l_len = strlen( ls_output ).
TRANSFER ls_output TO p_file LENGTH l_len.
ENDLOOP.
IF sy-subrc = 0.
ENDIF.
ENDDO.
CLOSE CURSOR l_cursor.
CLOSE DATASET p_file.
ENDFORM. " get_records
*& Form get_fields
FORM get_fields CHANGING pt_nametab TYPE ty_tab_nametab.
CALL FUNCTION 'RFC_GET_NAMETAB'
EXPORTING
tabname = 'BSEG'
TABLES
nametab = pt_nametab
EXCEPTIONS
table_not_active = 1
OTHERS = 2.
IF sy-subrc 0.
ENDIF.
ENDFORM. " get_fields
hope this helps.
cheers,
Hema.

Similar Messages

  • CALL function to extract data from a structure table

    Hi Gurus,
    Anyone knows how to write a call function to extract data from a structure table?
    Your help is very much appreciated.
    Thanks alot.

    Hi,
    structure doesnot hold any data. instead of it you can check the stucture in which table it is used, find the table name,use select query to extract the data u needed.
    you can use where used list option to find the structure in which table it is used.
    regards
    siva

  • How to extract data from SAP 4.7 and upload data to SAP ECC 6.0

    Hi,
        How to extract data from SAP 4.7 and upload data to SAP ECC 6.0? Can i use BDC,BAPI,LSMW? Help me please.

    hi
    good
    both works not possible simultaneously.
    If you want to do it in two separate task than you can use the GUI_UPLOAD function module to fulfill your requirement.
    thanks
    mrutyun^

  • Hi i am new to labview. i want to extract data from a text file and display it on the front panel. how do i proceed??

    Hi i am new to labview
    I want to extract data from a text file and display it on the front panel.
    How do i proceed??
    I have attached a file for your brief idea...
    Attachments:
    extract.jpg ‏3797 KB

    RoopeshV wrote:
    Hi,
    The below code shows how to read from txt file and display in the perticular fields.
    Why have you used waveform?
    Regards,
    Roopesh
    There are so many things wrong with this VI, I'm not even sure where to start.
    Hard-coding paths that point to your user folder on the block diagram. What if somebody else tries to run it? They'll get an error. What if somebody tries to run this on Windows 7? They'll get an error. What if somebody tries to run this on a Mac or Linux? They'll get an error.
    Not using Read From Spreadsheet File.
    Use of local variables to populate an array.
    Cannot insert values into an empty array.
    What if there's a line missing from the text file? Now your data will not line up. Your case structure does handle this.
    Also, how does this answer the poster's question?

  • Deletion of data from change log table and PSA

    Hi,
    For a DSO  I want to delete data from "Chnage log table"  and " PSA Tabel".
    For the DSO manage screen I have seen " Environment-> " Delete changelog table" from this we can delete chnage log table data as per my understanding.
    at PSA Level Mange screen also I have seen " Environment-> " Delete changelog table" from this option also it deletes the data from change log table or it deletes data from PSA table?.
    if this option also deletes data from changelog table then how we can delete data from PSA table?
    Please clarify me

    Hi,
      I am not sure what are you referring to from your point "PSA Level Mange screen also I have seen " Environment-> " Delete changelog table". When ever you click on manage for your psa you will be routed to a popup where you can see all your requests in the PSA table & there after if you click on any single request you will get Environment menu option but there wotn be any change log deletion option available. Please check again? Right clicking on your data source will take you to the manage requests for PSA. You can selectively delete the requests as required.
    For DSO when you right click on manage you can directly find Delete change log data option in the Environment tab. there you can select the requests you want to delete.
    Also if you want to automate the deletion process then you can simply create a chain and include the steps for PSA deletion & change Log deletion accordingly.
    Also it is recommended to keep on clearing the PSA table & Chage log data at regular intervals as it saves the disk space & thus helping in performance optimization
    Please refer the below doc at SDN, it will be helpful for you in automating the process of change log deletion & PSA deletion.
    http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/a02ba9e7-bb6f-2c10-09b4-e86b9fcbad41?QuickLink=index&overridelayout=true
    Hope it clears your doubts
    Thanks

  • Currency type 10,30 and 00 need to extract data from R/3 to BI

    Hi Experts,
    I am working ECC6.0 version with BI 7.0,
    I have a issue, when I extracting data from R/3 data source (0FI_AP_3) only currency type 10 comming but I need currency type 30 and 00 also....
    when I check in data source abap code it was hard coaded with 10 currenly only,
    can any help me to provide your inputs how currecy type 10, 30 and 00 also come to BI.
    Regards,
    Vijay

    Hi Vijay,
    0FI_AP_3 is Account payable -Actual line item data source, which was used for fetch actual vendor posting data.
    If you are looking for planning and budgeting data then you sud go for 0FI_AP_1 / 0FI_AP_6 / 0FI_AP_7 based on your requirement.
    Kindly let me know if you have any question on this.
    Regards,
    Ashish

  • Need Help:Reading Data from RU payroll cluster for table GRREC

    Hi...
    I need help on how to read data from RU cluster table for table GRREC for the employee & run date and get the value from structure PC292 .
    Please let me know about the includes and the import and export statements to be used.
    Thanks in advance,
    RAVI.

    Hi,
    Here goes pseudocode
    Includes:
    include: rpppxd00    ,
                rpppxd10     ,
                rpc2cd09     , 
                rpc2rx02_ce , "if ldb pnp_ce is used else use the same include with out _ce
                rpc2rx29      ,  
                rpc2rx39      ,
                rpppxm00    ,
                rpc2ruu0_ce ,
    Declare:
    DATA : i_rgdir   LIKE pc261        OCCURS 0 WITH HEADER LINE     ,
               i_result  TYPE pay99_result OCCURS 0 WITH HEADER LINE ,
               i_grrec   LIKE  pc292           OCCURS 0 WITH HEADER LINE .
    start-of-selection:
    GET pernr.
    Get the RGDIR VALUE for the current PERNR & selected Molga
    get rgdir data TABLES i_rgdir
                          USING pernr-pernr
                                     p_molga " parameter
    CD-KEY-PERNR = PERNR-PERNR.
    RP-IMP-C2-CU.
    i_rgdir [] = rgdir[].
      LOOP AT i_rgdir WHERE fpbeg  LE  pn-endda
                        AND fpend  GE  pn-begda
                        AND srtza  EQ 'A'
                        AND void   NE   'V'.
      get_result_tabs   TABLES i_result
                                   USING 'RU'    "  US cluster
                                         pernr-pernr
                                         i_rgdir-seqnr
          RX-KEY-PERNR = PERNR-PERNR.
          UNPACK i_RGDIR-SEQNR TO RX-KEY-SEQNO.
          RP-IMP-C2-RU.
      i_grrec[] = i_result-inter-grrec[].
      LOOP AT i_grrec.
      case i_grrec.
      use wage types required here and pass the data to output table.
      endcase.
      endloop.
      endloop
    end-of-selction.

  • How to extract data from a pool table?

    Hello,
    I want to create an generic extractor for table T030, but this is a pool/cluster table and it is not possible to create a view for such a table.
    Do somebody know how to solve this problem? Does there exist function modules to read the data from a pool data?
    Thanks
    Theodor

    Function Module would be your best bet..considering thats the best way as far as performance is taken into consideration.
    But there is a work around too...
    If the other table u use in the join is not a clusture table then u can create a view on that table and u can add append structure to this  with fields from the clusture table and use an exit to populate it.
    Try it Will Work...used this technique when I used KONV.* This Procedure does not decrease performance considerably.
    at least in my case as thre were only a few fields i needed from pool table
    Hope this Helps
    Anand Raj

  • Error while extracting data from Generic VBAK Table

    Hi,
    When i am extracting data from VBAK using generic extraction via tavle, i am, getting the error "Syntax error in program "SAPLXRSA ""
    What happened?
        Error in the ABAP Application Program
        The current ABAP program "SAPLRSAP" had to be terminated because it has
        come across a statement that unfortunately cannot be executed.
        The following syntax error occurred in program "SAPLXRSA " in include "ZXRSAU01
         " in
        line 159:
        "The type of the database table and work area (or internal table) "L_ST"
        "R_CE1IDEA" are not Unicode convertible. ."
    Please help me out in fixing this,
    Thansk,

    do you have an user-exit? if yes, post the code....
    did you try regenerating the entire stuff (ds, structure,...)...there might be a mismatch between the structures of datasource and the generated extraction program....
    M.

  • Error when extracting data from ETL - Missing messages and missing InfoIdoc

    Hi All,
    We are using BW 3.0 and extracting data from other source systems through Informatica Powercenter (ETL). The system is working fine but when we try to extract data on 31st Dec , we get the following error. Only this load gives the error and all the other load to other data targets are going fine. All the data are one-to-one mapped from ETL to BW.
    Error messages from Monitor -Status tab:-
       "InfoIdocs missing; external system
       Diagnosis :- InfoIDocs are missing. The IDocs are created in BW with non-SAP systems as source    
       systems that transfer the data and metadata to BW using BAPIs. Since the IDocs are missing, a   
       short dump in BW probably occurred.
       System response:  No selection information arrived from the source system"
    Error messages from Monitor -Details tab:-
        Missing message: Number of sent records,   Missing message: Selection completed
    Highly appretiate your suggestions.
    Vinod.CH

    Hi Rathy Moorthy,
    Thank you very much for your reply. The source system connections are OK and we are able to load data to other Data targets from ETL, we have issue only with this this particular load. The load extracts data and I have loaded the data from ETL to PSA and have checked the data content and it is correct. But when I update the same data to the target I get this error. I have also tried to update from PSA to target and also directly from ETL to target.
    Appretiate your suggestions.

  • Fetch data from a R3 Table and send to XI

    Hello XI Experts,
                     I am involved in a scenario where i need to read some data from a Transparent table in R3 send to xi and post a CSV File.
    I have worked on look ups at the XI abap stack but i want to know which is the best solution to do this.
    What's the best way to read a table from R/3 and send to xi server. Is there any other ways besides Look ups? 
    Regards,
    Anirban.

    Hi,
    >>>1. When is look ups advised .
    a lookup is when somewhere in your
    interface flow you have to lookup some data
    for example you send data from one system to another but you have to change material numbers before
    sending the data to the target system
    you know that material numbers are inside some other server so you have to call this sever (very often in a sync way) to lookup the material numbers
    so this would be difficult with IDOC for instance
    >>> 2. Which is a better solution, if i have very few data to fetch with WAS >= 6.20 . Abap Proxy Or a 'Z' Idoc.
    you'll be able to do it quicker with ABAP proxy
    if you use a scheduled report that will send the data from r3 then use ABAP proxies
    Regards,
    michal

  • Getting Sales document data from VBKD to the Account Receivable Line items

    Hi Friends,
    We have to enhance 0FI_AR_4 With the Sales data from the VBKD Table where we can have Sales document Number.
    Can you please let me know how to make link with FI-AR  Accounting document with Sales documewnt. So that I can get data from the VBKD table.
    Thanks &Regards,
    Revathi

    Hi,
    Sales document(VBELN) is already avialable in 0FI_AR_4. Also see the link  http://help.sap.com/saphelp_tm80/helpdata/en/70/10e73a86e99c77e10000000a114084/content.htm.
    Regards,
    Prakash

  • AQ or Streams to replicate data from a database table and put it on a queue

    If was tasked with the above if I was using AQ I'd think about publishing to queue via insert trigger on a table that's the destination end of a replication.
    Given that there's replication involved it sounds like if you want to replicate data from A to B and also push it to a queue you should be thinking Streams with a transform and not just AQ.
    However, how do you get Streams to replicate from A to B and at the same time and in the same transaction transform a message and put it on a queue?
    Also, if you are to build the message in XML and use an XML payload what do you use to construct the message? PL/SQL by hand? Are there API's in PL/SQL to build a DOM and then stringify the DOM you've built such that everything is entity encoded correctly and the payload can be published to a queue as an XML payload?

    Oh yes sorry I lost track of which thread this was. I was thinking Streams but I forgot the original suggestion was to use triggers.
    We have many use cases today where data arrives via inserts into some table and a process polls this table and processes the data. This approach does not scale very well. Currently these polling processes are polling the same database that is constantly inserting data as it arrives via multple processes.
    I am trying to move away from this approach by introducing queuing. In addition to the above we also have an approach where as the data arrives it's placed on a queue and the process processes these messages asynchonously from the queue. Currently this queue based implementation does not use Oracle. I am trying to move to a solution where if the data must arrive via inserts into a database the processing of the data doesn't necessarily have to be by fetching those records out of the table thru polling. The general idea is that as the messages are inserted they are subsequently enqueued and processed off a queue. There is no desire to have a process which simply polls the database and enqueues what I find in the table. The goal is to remove constant polling of the database.

  • Help needed in  extracting data from PCD tables

    Hi Friends
    I Have a requiremnt for creating custom portal activity report ,even though
    we have  standard report, the extraced data will be used to create bw reports later.
    my part is to find a way to extract the data from PCD tables for creating
    custom portal activity reports
    i have selected the following  tables for the data extraction
    WCR_USERSTAT,WCR_WEBCONTENTSTAT,WCR_USERFIRSTLOGON,
    WCR_USERPAGEUSAGE.
    My questions are
    1.Did i select the Exact PCD tables?
    2.Can i use UME api  for  accessing the data from those tables?
    3.can i use  the data extracted  from PCD tables in JSPdynpage  or
    webdynpro apps?
    4.can i Querry  the  PCD tables from  JSPDynpage or Webdynpro
    Please help me in finding a solution for this
    Thanks
    Ashok Battula

    Hi daniel
    Can u tell  me weather i can develop the following  custom reports from those WCR tables
         Report Type
    1     Logins
          - Unique Count
          - Total Count
          - Most Active Users (by Partner Name)
          - Most Active Users (by Contact Name)
          - Entry Point (by page name)
          - Session Time
          - Hourly Traffic Analysis
    2     Login Failures
          - Total Count
          - Count by error message
          - Credentials Entered (by user name and password)
    3     Content Views (by File Name)
          - Unique Count
          - Total Count
          - Most requested Files
          - Most requested Pages
          - File Not Found
    4     Downloads (by File Name)
          - Unique Count
          - Total Count
          - Most requested Files
          - File Not Found
    5     Portal Administration
          - Site Content (by file name)
          - Site Content (by page name)
          - Latest Content (by file name)
          - Expired Content (by file name)
          - Subscriptions Count (by file name)
    6     Login History (by Partner, Contact Name)
          - No Login
          - First Login
          - Duration between registration and first login
          - Most Recent Login
          - Average Number of Logins
    plz  help me in find ing a way
    thanks
    ashok

  • Need to extract data from R/3 to BI...

    Hi Friends,
    We need to extract some data available in the R/3 side to BI. I have written code in a function module which brings the output into the table e_t_data. now by attaching this function module, we created a Data source also. and then from BI side we replicated this Datasource. when tried to extract the data at BI from R/3, the process keeps on running with out bringing any data into BI. 
    Regarding this, i referred some docs in the forums. They say that we have to go with the approach followed in the FM 'RSAX_BIW_GET_DATA_SIMPLE'. I have done all the coding and settings similar to this function module. there is no syntax error and code produces the required output in e_t_data.In that FM they used some Select statement under the Open Cursor statement. But in our requirement, we are not selecting anything from Table. but we generate some data by some calculations and these data will be our output. If it is the case, can't we use that open cursor approach...?  we need to get the output data not by any select statement  but the output will be some internal table entries which are created by some calculations.
    Please suggest how to handle this. That would be very much helpful. <removed_by_moderator>
    Thanks in advance...
    Regards
    Ram
    Edited by: Julius Bussche on Jul 14, 2008 2:17 PM

    If you dont require any coding, then why dont you extract the data using the DB view/table or DB query. why you are using the FM.
    If you are using the FM, then for the first extraction call it will pass the selectoption data into ranges and in the next extraction call it will open the cursor based on the input data and fetch the data according to the package size per extraction call.
    For the generic data sources using the FM, the main thing lies in Fetching the data. If you study the standard FM 'RSAX_BIW_GET_DATA_SIMPLE', it fetches the data according to the number of records per extraction call.
    At the BI, entire data cant be picked up at once. it will pick packets of data.
    Regards
    Kannaiah

Maybe you are looking for

  • Numeric character problems when creating spatial index

    Hi, We have run into a problem when trying to create spatial indexes. The problem seems to be that an mdsys-procedure tries to use a number with a comma as decimal symbol in an update statement Error message: ERROR at line 1: ORA-29855: error occurre

  • Cannot call pacman through schroot

    I have a 32-bit chroot setup which I use for building i686 packages.  Ever since upgrading to pacman4, I am unable to call pacman through the shcroot command: Example: $ schroot -p -- sudo pacman -S libnetfilter_queue resolving dependencies... lookin

  • I want the image preview put back into PS CS6 file open dialog box (WIndows)

    PATCH IT NOW ADOBE!!!

  • DB2 v7.1 JDBC type 4 drivers?

    Hello, Does any one have a link to IBM DB2 JDBC type 4 drivers? I can't find anything from IBM site. IBM sites are very confusing to navigate and it is impossible to find any using information. Thanks, Minh Huynh

  • OBIEE Basic and OBIEE FS Licence

    Hi, I need to know if OBIEE Basic license can connect to Hyperion Essbase and create dashboards. Or is it that OBIEE FS license is a must have for connecting to Hyperion Essbase and for creation of dashboards. Sid