Extracting data from iDoc tables

Hi,
I need to extract data from idoc segments from the database tables EDIDC and EDID4 for which the idoc status is 51 and to save all this data in an external file.
For example, I need to check all the iDocs with WPUBON01 base type and if the status is 51 then I have to query the ARTNR field from E1WPB02 segment and to save idoc number and ARTNR in an excel file.
Can anybody help me or give me some example?
Thank you in advance.
Ioan

See Below Example code :
TYPE-POOLS: slis.
tables : edid4 , edidc ,edids ,lfa1,teds2.
DATA: t_fieldcatalog TYPE slis_t_fieldcat_alv.
DATA: s_fieldcatalog TYPE slis_fieldcat_alv.
DATA: s_layout TYPE slis_layout_alv.
DATA: text11 LIKE E1EDP02.
DATA: text111 LIKE E1MBXYI.
DATA: s_keyinfo TYPE slis_keyinfo_alv.
DATA: v_repid TYPE syrepid.
DATA: V_MSGNO LIKE T100-MSGNR.
*DATA: V_TEXT(90).
DATA : WA_EDIDS TYPE EDIDS.
data : begin of itab_edids occurs 0,
   user like edids-UNAME,
   date like edids-CREDAT,
   time like edids-cretim,
   idoc like edids-docnum,
  MESSAGETYPE like edidc-MESTYP,
  VENDOR LIKE EDIDC-SNDPRN,
  name like lfa1-name1,
  icon(1),
   EXPAND TYPE C,
end of itab_edids.
data : itab type edid4.
data : begin of itab_edidc occurs 0,
     doc_num like edidc-docnum,
     MESSAGETYPE like edidc-MESTYP,
   IDOCTYPE like edidc-DOCTYP,
   PARTNERNUMBER like edidc-RCVPRN,
   PARTNERTYPE like edidc-RCVPRT,
  MESSAGECODE like edidc-MESCOD,
  VENDOR LIKE EDIDC-SNDPRN,
  data like edidc-credat,
*include structure edidc.
  end of itab_edidc.
data : begin of itab_status occurs 0,
idoc like edids-docnum,
date_stauus like edids-logdat,
status_counter like edids-countr,
staTus like edids-status,
*descrp like teds2-descrp,
DESCRP(70),
ponumber like  ekpo-ebeln,
MESS LIKE edidc-MESTYP,
*appdoc like edids-stapa1,
end of itab_status.
data : text like edid4-sdata.
DATA: text1 LIKE E1EDK01.
data : begin of itab_teds1 occurs 0.
        include structure teds1.
data end of itab_teds1.
*selection-screen begin of block sb with frame title text-001.
*select-options:
   s_rsdat for edidc-CREDAT.
*selection-screen end of block sb.
DATA: f_fieldcatalog TYPE slis_fieldcat_alv.
selection-screen begin of block sb with frame title text-001.
parameters:
       p_su radiobutton group gp1,
       p_re radiobutton group gp1,
       p_al radiobutton group gp1.
select-options:
    s_rsdat for edids-creDAT,
    s_user for edids-uname.
selection-screen end of block sb.
initialization.
PERFORM INITIALIZATION.
start-of-selection.
PERFORM DATA_RETRIVAL.
PERFORM DATA_BASED_SELECTION.
PERFORM PASSING_ALV.
*select docnum mestyp doctyp rcvprn rcvprt mescod credat into
*table itab_edidc from edidc
*where credat in s_rsdat.
*CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
*EXPORTING
*i_program_name = v_repid
*I_INTERNAL_TABNAME = 'ITAB_STATUS'
*CHANGING
*ct_fieldcat = t_fieldcatalog.
*CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
*EXPORTING
*i_program_name = v_repid
*I_INTERNAL_TABNAME = 'ITAB_EDIDS'
*CHANGING
*ct_fieldcat = t_fieldcatalog.
s_LAYOUT-ZEBRA = 'X'.
*s_LAYOUT-SUBTOTALS_TEXT = 'SUBTOTAL'.
*s_LAYOUT-TOTALS_TEXT = 'TOTAL'.
*&      Form  INITIALIZATION
      text
-->  p1        text
<--  p2        text
FORM INITIALIZATION.
V_REPID = SY-REPID.
  s_keyinfo-header01 = 'IDOC'.
  s_keyinfo-item01 = 'IDOC'.
*s_layout-subtotals_text = 'SUBTOTAL TEXT'.
*s_layout-key_hotspot = 'X'.
*s_layout-expand_fieldname = 'EXPAND'.
  CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
       EXPORTING
            i_program_name         = V_REPID
            I_INTERNAL_TABNAME     = 'ITAB_STATUS'
            I_INCLNAME = V_repid
       CHANGING
            ct_fieldcat            = T_fieldcatalog
       EXCEPTIONS
            INCONSISTENT_INTERFACE = 1
            PROGRAM_ERROR          = 2
            OTHERS                 = 3.
  CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
       EXPORTING
            i_program_name         = V_REPID
            I_INTERNAL_TABNAME     = 'ITAB_EDIDS'
            I_INCLNAME = V_repid
       CHANGING
            ct_fieldcat            = T_fieldcatalog
       EXCEPTIONS
            INCONSISTENT_INTERFACE = 1
            PROGRAM_ERROR          = 2
            OTHERS                 = 3.
f_fieldcatalog-just = 'L'.
MODIFY t_fieldcatalog FROM f_fieldcatalog
TRANSPORTING just
WHERE  ( fieldname = 'IDOC' OR FIELDNAME = 'STATUS_COUNTER' ).
f_fieldcatalog-SELTEXT_L = 'Status Message'.
MODIFY t_fieldcatalog FROM f_fieldcatalog
TRANSPORTING SELTEXT_L
WHERE  fieldname = 'DESCRP'.
f_fieldcatalog-TECH = 'X'.
MODIFY t_fieldcatalog FROM f_fieldcatalog
TRANSPORTING TECH
WHERE  fieldname = 'EXPAND'.
f_fieldcatalog-REPTEXT_DDIC = 'Vendor Name'.
MODIFY t_fieldcatalog FROM f_fieldcatalog
TRANSPORTING REPTEXT_DDIC
WHERE  fieldname = 'NAME'.
*f_fieldcatalog-REPTEXT_DDIC = 'V Code 32122'.
*MODIFY t_fieldcatalog FROM f_fieldcatalog
*TRANSPORTING REPTEXT_DDIC
*WHERE  fieldname = 'VENDOR'.
ENDFORM.                    " INITIALIZATION
*&      Form  DATA_RETRIVAL
      text
-->  p1        text
<--  p2        text
FORM DATA_RETRIVAL.
select  uname credat cretim docnum into  table
itab_edids from edids
               where credat in s_rsdat and
                      uname in s_user and
                      countr = ' '.
select  uname credat cretim docnum from edids
*APPENDING CORRESPONDING FIELDS OF TABLE itab_edids
              where logdat in s_rsdat and
                     uname in s_user.
                     SELECT budat hkont belnr shkzg wrbtr FROM bsas
*APPENDING CORRESPONDING FIELDS OF TABLE it_temp WHERE hkont = w_glacct
*"wa_cb-gl_account
*AND bukrs IN (so_bukrs-low)
*AND budat < so_date-low.
  delete  adjacent duplicates from itab_edids.
  if not itab_edids[]  is initial.
     select docnum mestyp doctyp rcvprn rcvprt mescod SNDPRN credat into
    table itab_edidc from edidc for all entries in itab_edids
    where docnum = itab_edids-idoc.
  endif.
LOOP AT ITAB_edids.
   READ TABLE ITAB_EDIDC WITH KEY  DOC_NUM = ITAB_EDIDS-IDOC.
   itab_edids-messagetype = ITAB_EDIDC-MESSAGETYPE.
   itab_edids-VENDOR = ITAB_EDIDC-VENDOR.
   MODIFY ITAB_EDIDS.
   CLEAR ITAB_EDIDS.
   ENDLOOP.
DELETE ITAB_EDIDC WHERE MESSAGETYPE = 'ORDERS'.
loop at itab_edids.
read table itab_edidc with key doc_num  = itab_edids-idoc.
if sy-subrc ne 0.
delete itab_edids.
endif.
endloop.
select docnum logdat countr status into table itab_status from edids for
   all entries in itab_edidc where docnum = itab_edidc-doc_num.
   LOOP AT ITAB_STATUS.
   READ TABLE ITAB_EDIDC WITH KEY  DOC_NUM = ITAB_STATUS-IDOC.
   ITAB_STATUS-MESS = ITAB_EDIDC-MESSAGETYPE.
   MODIFY ITAB_STATUS.
   CLEAR ITAB_STATUS.
   ENDLOOP.
  loop at itab_status.
    clear : text ,text1 , text11, text111, itab.
   select single descrp from teds2 into itab_status-descrp
                          where status = itab_status-STATUS AND
                               LANGUA = 'E'.
   select single sdata into text from edid4 where
     DOCNUM =  itab_status-idoc and
     segnam = 'E1EDK01'.
*MOVE: text        TO text1,
     text1-BELNR TO itab_status-ponumber.
      itab_status-ponumber = text1-belnr.
   move text+83(30) to itab_status-ponumber.
   MODIFY ITAB_STATUS.
   clear itab_status.
IF itab_status-MESS = 'WMMBXY'.
   select single * from edid4  INTO ITAB where segnam = 'E1MBXYI' AND
                 HLEVEL = '02' AND DOCNUM = itab_status-idoc.
MOVE  : ITAB-SDATA  TO TEXT111 ,
text111-EBELN TO itab_status-ponumber.
**text1-BELNR TO ponumber.
ELSE.
select single * from edid4  INTO ITAB where segnam = 'E1EDP02' AND
                 HLEVEL = '03' AND DOCNUM = itab_status-idoc.
MOVE  : ITAB-SDATA  TO TEXT11 ,
*text1-EBELN TO ponumber.
text11-BELNR TO itab_status-ponumber.
endif.
    MODIFY ITAB_STATUS.
    clear itab_status.
  endloop.
ENDFORM.                    " DATA_RETRIVAL
*&      Form  PASSING_ALV
      text
-->  p1        text
<--  p2        text
FORM PASSING_ALV.
s_LAYOUT-EXPAND_FIELDNAME = 'EXPAND'.
DATA: t_events TYPE slis_t_event.
DATA: s_events LIKE LINE OF t_events.
s_events-form = 'TOP_OF_PAGE'.
s_events-name = 'TOP_OF_PAGE'.
APPEND s_events TO t_events.
s_layout-lights_fieldname = 'ICON'.
sort itab_status by status_counter descending. " -
mod3
  CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'
       EXPORTING
            i_callback_program = v_repid
            is_layout          = s_layout
            it_fieldcat        = t_fieldcatalog
            i_callback_user_command = 'USER_COMMAND'
            i_tabname_header   = 'ITAB_EDIDS'
            i_tabname_item     = 'ITAB_STATUS'
            IT_EVENTS          = t_events
            is_keyinfo         = s_keyinfo
       TABLES
            t_outtab_header    = itab_EDIDS
            t_outtab_item      = itab_STATUS
       EXCEPTIONS
            program_error      = 1
            OTHERS             = 2.
  IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.
ENDFORM.                    " PASSING_ALV
*&      Form  DATA_BASED_SELECTION
      text
-->  p1        text
<--  p2        text
FORM DATA_BASED_SELECTION.
if p_su eq 'X'.
*loop at itab_status where status = '53'.
*select single stapa1 from edids into itab_status-appdoc
where  docnum = itab_status-idoc and status = '53'.
*delete itab_status where status ne '53'.
*modify itab_status.
*endloop.
delete itab_status where status ne '53'.
loop at itab_edids.
read table itab_status with key idoc = itab_edids-idoc binary search.
if sy-subrc ne 0.
delete itab_edids.
ELSE.
*SHIFT ITAB_EDIDS-IDOC LEFT  DELETING LEADING '0'.
MODIFY ITAB_EDIDS.
endif.
endloop.
LOOP AT ITAB_STATUS WHERE MESS NE 'WMMBXY'.
SELECT SINGLE * FROM EDIDS INTO WA_EDIDS WHERE DOCNUM = ITAB_STATUS-IDOC
AND COUNTR = ITAB_STATUS-STATUS_COUNTER.
IF  WA_EDIDS-STATXT CA '&'.
V_MSGNO = WA_EDIDS-STAMNO.
IF V_MSGNO NE '000'. "----mod3
CALL FUNCTION 'MESSAGE_PREPARE'
EXPORTING
msg_id = WA_EDIDS-STAMID
msg_no = V_MSGNO
MSG_VAR1 = wa_edids-stapa1
MSG_VAR2 = WA_EDIDS-STAPA2
MSG_VAR3 = WA_EDIDS-STAPA3
MSG_VAR4 = WA_EDIDS-STAPA4
IMPORTING
MSG_TEXT = itab_status-descrp.
CONDENSE ITAB_STATUS-DESCRP.
ENDIF."---- mod3
ELSE .
ITAB_STATUS-DESCRP = WA_EDIDS-STATXT.
ENDIF.
*SHIFT ITAB_STATUS-IDOC LEFT  DELETING LEADING '0'.
*SHIFT ITAB_STATUS-STATUS_COUNTER LEFT  DELETING LEADING '0'.
MODIFY ITAB_STATUS.
ENDLOOP.
LOOP AT ITAB_STATUS WHERE MESS EQ 'WMMBXY'.
SHIFT ITAB_STATUS-IDOC LEFT  DELETING LEADING '0'.
SHIFT ITAB_STATUS-STATUS_COUNTER LEFT  DELETING LEADING '0'.
ITAB_STATUS-DESCRP = 'APPLICATION DOCUMENT POSTED'.
MODIFY ITAB_STATUS.
ENDLOOP.
delete adjacent duplicates from  itab_edids comparing idoc.
elseif p_re eq 'X'.
loop at itab_status where status = '53'.
delete itab_edids where idoc = itab_status-idoc.
endloop.
loop at itab_status.
read table itab_edids with key idoc = itab_status-idoc binary search.
if sy-subrc ne 0.
delete itab_status.
endif.
endloop.
LOOP AT ITAB_STATUS.
SELECT SINGLE * FROM EDIDS INTO WA_EDIDS WHERE DOCNUM = ITAB_STATUS-IDOC
AND COUNTR = ITAB_STATUS-STATUS_COUNTER.
IF  WA_EDIDS-STATXT CA '&'.
V_MSGNO = WA_EDIDS-STAMNO.
IF V_MSGNO NE '000'. "----mod3
CALL FUNCTION 'MESSAGE_PREPARE'
EXPORTING
msg_id = WA_EDIDS-STAMID
msg_no = V_MSGNO
MSG_VAR1 = WA_EDIDS-STAPA1
MSG_VAR2 = WA_EDIDS-STAPA2
MSG_VAR3 = WA_EDIDS-STAPA3
MSG_VAR4 = WA_EDIDS-STAPA4
IMPORTING
MSG_TEXT = itab_status-descrp.
CONDENSE ITAB_STATUS-DESCRP.
endif. "-----mod3
ELSE .
ITAB_STATUS-DESCRP = WA_EDIDS-STATXT.
ENDIF.
SHIFT ITAB_STATUS-IDOC LEFT  DELETING LEADING '0'.
SHIFT ITAB_STATUS-STATUS_COUNTER LEFT  DELETING LEADING '0'.
MODIFY ITAB_STATUS.
ENDLOOP.
LOOP AT ITAB_EDIDS.
SHIFT ITAB_EDIDS-IDOC LEFT  DELETING LEADING '0'.
MODIFY ITAB_EDIDS.
ENDLOOP.
delete adjacent duplicates from  itab_edids comparing idoc.
elseif p_al eq 'X'.
delete adjacent duplicates from  itab_edids comparing idoc.
LOOP AT ITAB_STATUS." WHERE MESS NE 'WMMBXY'.
SELECT SINGLE * FROM EDIDS INTO WA_EDIDS WHERE DOCNUM = ITAB_STATUS-IDOC
AND COUNTR = ITAB_STATUS-STATUS_COUNTER.
IF  WA_EDIDS-STATXT CA '&'.
V_MSGNO = WA_EDIDS-STAMNO.
IF V_MSGNO NE '000'. "----mod3
CALL FUNCTION 'MESSAGE_PREPARE'
EXPORTING
msg_id = WA_EDIDS-STAMID
msg_no = V_MSGNO
MSG_VAR1 = WA_EDIDS-STAPA1
MSG_VAR2 = WA_EDIDS-STAPA2
MSG_VAR3 = WA_EDIDS-STAPA3
MSG_VAR4 = WA_EDIDS-STAPA4
IMPORTING
MSG_TEXT = itab_status-descrp.
CONDENSE ITAB_STATUS-DESCRP.
endif. "----mod3
ELSE .
ITAB_STATUS-DESCRP = WA_EDIDS-STATXT.
ENDIF.
*SHIFT ITAB_STATUS-IDOC LEFT  DELETING LEADING '0'.
*SHIFT ITAB_STATUS-STATUS_COUNTER LEFT  DELETING LEADING '0'.
MODIFY ITAB_STATUS.
ENDLOOP.
endif.
LOOP AT ITAB_EDIDS.
  if p_su EQ 'X'.
  itab_edids-icon = '3'.
  elseif p_re eq 'X'.
   itab_edids-icon = '1'.
   ELSE.
   read table itab_sTATUS with  key idoc = itab_EDIDS-idoc
                               STATUS  = '53' ."binary search.
   IF SY-SUBRC EQ 0.
    itab_edids-icon = '3'.
   ELSE.
   itab_edids-icon = '1'.
   ENDIF.
   ENDIF.
select single name1 from lfa1 into itab_edids-name where
            lifnr = itab_edids-vendor.
SHIFT ITAB_EDIDS-IDOC LEFT  DELETING LEADING '0'.
MODIFY ITAB_EDIDS.
clear itab_edids.
ENDLOOP.
loop at itab_status.
SHIFT ITAB_STATUS-IDOC LEFT  DELETING LEADING '0'.
SHIFT ITAB_STATUS-STATUS_COUNTER LEFT  DELETING LEADING '0'.
if itab_status-descrp is initial.
select single descrp from teds2 into itab_status-descrp
                           where status = itab_status-STATUS AND
                                LANGUA = 'E'.
endif.
MODIFY ITAB_STATUS.
clear itab_status.
endloop.
sort itab_status by idoc.
sort itab_edids by idoc.
ENDFORM.                    " DATA_BASED_SELECTION
*& Form TOP_OF_PAGE
text
FORM TOP_OF_PAGE.
SKIP.
ULINE.
IF P_SU EQ 'X'.
WRITE : / 'TITLE : SUCCESSFULLY POSTED IDOC', 50 'DATE :', SY-DATUM..
ELSEIF P_RE EQ 'X'.
WRITE : / 'TITLE : REJECTED IDOCS'  ,50 'DATE :', SY-DATUM.
ELSEIF P_AL EQ 'X'.
WRITE : / 'TITLE : ALL IDOCS' ,50 'DATE :', SY-DATUM.
ENDIF.
WRITE  :/9 'Successful-Green light  Unsuccessful-Red Light'.
format color COL_TOTAL intensified on.
WRITE : / 'NOTE  : DOUBLE CLICK TO SEE CORREPONDING IDOC AND PO'.
WRITE :/9 'DOUBLE CLICK IDOC NO ON HEADER LIST'.
WRITE :  'AND PO NUMBER ON DETAIL LIST'.
format color off.
ULINE.
SKIP.
ENDFORM. "TOP_OF_PAGE
FORM user_command *
--> UCOMM *
--> SELFIELD *
FORM user_command USING ucomm LIKE sy-ucomm
selfield TYPE slis_selfield.
DATA: WA_IDOC9 LIKE EDIDC-DOCNUM.
DATA: SELTAB     TYPE TABLE OF RSPARAMS,
      SELTAB_WA  LIKE LINE OF SELTAB.
RANGES : R_DATE FOR EDIDC-CREDAT." SY-DATUM.
IF ucomm = '&IC1'.
if SELFIELD-SEL_TAB_FIELD = 'ITAB_EDIDS-IDOC'.
READ TABLE itab_edids INDEX selfield-tabindex.
IF sy-subrc = 0.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = ITAB_edids-IDOC
IMPORTING
OUTPUT = WA_IDOC9.
*r_date-low = itab_edids-date.
*r_date-high = itab_edids-date.
*r_date-SIGN = 'I'.
*r_date-OPTION = 'BT'.
*append r_date.
SUBMIT RSEIDOC2  WITH DOCNUM = wa_idoc9
WITH CREDAT in R_DATE[]  AND RETURN.
ENDIF.
ELSEIF SELFIELD-SEL_TAB_FIELD = 'ITAB_STATUS-PONUMBER'.
READ TABLE itab_STATUS INDEX selfield-tabindex.
IF sy-subrc = 0.
SET PARAMETER ID 'BES' FIELD itab_sTATUS-PONUMBER.
CALL TRANSACTION 'ME23N' AND SKIP FIRST SCREEN.
ENDIF.
ENDIF.
ENDIF.
ENDFORM..

Similar Messages

  • How to extract data from multiple tables (always got errors)

    Dear Experts,
    I have a simple mapping to extract data from multiple tables as a source (A, B, C) to a target table (X). Below is the picture:
    (Sources)....(Target)
    A----------------***
    B----------------X
    C----------------***
    Sample Source Data:
    Table A:
    ColA1
    100
    200
    etc
    Table B:
    ColB1 ColB2 ColB3
    10 Y Ten
    20 Y Twenty
    30 Y Thirty
    etc
    Table C:
    ColC1 ColC2
    11
    12
    13
    etc
    Target table (X) should be (just has 1 group INGRP1):
    ColA1 ColB1 ColB3 ColC1
    100 10 Ten 11
    100 10 Ten 12
    100 20 Twenty 21
    etc
    Scenarios:
    1. Directly map from A, B, C to X. Unable to map with error message: "API8003: Connection target attribute group is already connected to an incompatible data source. Use a Joiner or Set operator to join the upstream data first before connecting it into this operator."
    2. Map each source to Expression Operator and then map from each Expression to target table. I am able to map all attributes successfully but got error when validating it with message: "VLD-1104: Attributes flowing into TEST.EXPR_SRC.INGRP1 have different data sources."
    How can I achieve the correct mapping for this purpose?
    Use Joiner? I have no key to join the sources
    Use Set? The sources have different number of columns
    Thanks in advance
    Prat

    Thanks Nico,
    I think it will results data like this:
    100 10 Ten 11
    200 20 Twenty 12
    300 30 Thirty 13
    etc
    and not the expected:
    100 10 Ten 11
    100 10 Ten 12
    100 20 Twenty 21
    etc
    But it inspired me to solve this by adding key expression in each source table (B & C) to be joined to table A with this formula:
    100+TRUNC(INGRP1.COLB1,-2)
    Regards
    Prat

  • How to extract data from 12 tables ?

    Hi experts,
    I want to extract data from 12 tables into bi.
    How can we do this. And also can we extract some fields from
    a structure?
    Full points will be assigned.
    Regards,
    V N.

    Hi,
    First you need to check if the tables are standard tables or custom tables. If they are standard tables check which extractors are using those tables.
    If they are not being used by any of the standard extractors then you you need to create generic datasource for the same. The same hold true for custom tables as well. For custom tables, you'll need to create generic datasource. If you search the forum for generic datasources you'll get a lot of information.
    Its very important that you understand the table relationships, data volumes, if delta is possible or not, data granularity, etc for your datasource design.
    Cheers,
    Kedar

  • Extract data from a table

    Hi All,
    How to extract data from a table to a excel sheet.
    I want matnr and desc from MARA.
    Please help me.
    Thanks
    Veni

    Programmatically it would like something like this.
    report  zrich_0001.
    data: begin of imakt occurs 0,
          matnr type makt-matnr,
          maktx type makt-maktx,
          end of imakt.
    start-of-selection.
      select matnr maktx into table imakt from makt.
      call method cl_gui_frontend_services=>gui_download
        exporting
    *      BIN_FILESIZE              =
          filename                  = 'C:makt.xls'
           write_field_separator     = 'X'
        changing
          data_tab                  = imakt
        exceptions
          others                    = 24
    Regards,
    Rich Heilman

  • JDBC-XI-FILE scenario. How to extract data from multiple tables

    Hi,
    At this moment I didn't have the access for XI system. So here I have some silly question. Could you please clarify the same ??
    If I got to extract data from single table using JDBC adapter I can put the below query in communication channel
    SELECT *FROM orders WHERE new='true'.
    But if I got to extract data from multiple tables, logic to be used should be like as shown below. ( from previous thread------prabhu).
    SELECT <Table_2>.EID, <Table_2>.FName, <Table_2>.LName, <Table_1>.REC_DAT, <Table_1>.DESCRP
    FROM <Table_1> INNER JOIN <Table_2> on
    <Table_1>.CARDNO = <Table_2>.CARD
    where REC_DAT = <condition>
    union
    SELECT <Table_2>.EID, <Table_2>.FName, <Table_2>.LName, <Table_1>.REC_DAT, <Table_1>.DESCRP
    FROM <Table_1> INNER JOIN <Table_2> on
    <Table_1>.CARDNO = <Table_2>.CARD
    where REC_DAT = <condition>
    But my query is ........how to put the above entire code in one line. (i.e in Qery place of communication channel ) ??
    Thanks
    Kumar

    Hi Palnati,
        You either use a select query with join or a stored procedure which will contain the logic to extract the data from multiple tables. But, the limitation in case of stored procedure is u can hv only one selct query in it.
    You write ur actual query provided in the parameter 'Query SQL Statement". u can also wrt a stored procedure in it. Also, u can provide a update statement in it which will update a certain flag so tht u don selct the data again.
    Check the following link
    <a href="http://help.sap.com/saphelp_nw04/helpdata/en/14/80243b4a66ae0ce10000000a11402f/frameset.htm">http://help.sap.com/saphelp_nw04/helpdata/en/14/80243b4a66ae0ce10000000a11402f/frameset.htm</a>
    Regards,
    Akshay
    Message was edited by:
            Akshay Salunke

  • Extracting data from ECC tables in BODS

    Hello all,
    I'm trying to extract data from ECC tables. I have created a data store and imported the necessary tables(FAGLFLEXT) that i will be using.  I have used the table in a job as a source and tried to execute the job but i was only able to extract 28 records from the extractor when there are many more records present in the table and  also when i view the data in BODS i can only see 28 records.
    Plz help me in resolving this. How to extract the whole data?
    Thanks in advance.

    The table layouts can be found in the [documentation for EPMA|http://www.oracle.com/technetwork/middleware/bi-foundation/epm-data-models-11121-354684.zip] . If this doesn't work, there are other options to export hierarchies to text files. You can use life cycle management or the [EPMA File Generator|http://docs.oracle.com/cd/E17236_01/epm.1112/epma_file_gen_user/launch.html].
    Kyle Goodfriend
    http://www.in2hyperion.com
    Please make sure you assign your post as answered when an appropriate answer is provided (or helpful when applicable) so others benefit.

  • Extract data from database tables and download in pdf and csv

    extract data from database tables and download in pdf and csv
    hi how can i re-write my old form procedure in adf java. the procedure used to extract data from diffirent table and dowload the data in pdf and csv.am not downloading image, i what to extract data from diffirent tables in my database and download that data in pdf and csv. i would like to write this in java adf.i just what direction am not asking anyone to do my work this is my learning curve
    the form code is
    function merge_header3 return varchar2 is
    begin
         return '~FACILITY DESCRIPTION~ACCOUNT NO~BRANCH CODE~BANK REF NO.~P/P/ AMOUNT~Postal Address 1~Postal Address 2~Box Postal Code~Dep. Date~Month~BANK NAME~BRANCH NAME~ACCOUNT TYPE~DESCRIPTION~OBJECTIVE DESCRIPTION';
    end;
    procedure download_file (i_pbat integer) is
      dir varchar2(80);
      file_name1 varchar2(80);
      file_name2 varchar2(80);
      appl_code varchar2(80);
      fil1 client_text_io.file_type;
      fil2 client_text_io.file_type;
      dat varchar2(1000);
      DATA VARCHAR2(1000);
      bvspro varchar2(100);
      ssch   varchar2(100);
      bvspro_total number(20,2);
      ssch_total   number(20,2);
      grand_total  number(20,2);
      cnt    integer;
      cursor pbat is
           select *
           from sms_payment_batches
           where id = i_pbat
      cursor pay  (pb_id integer) is
           select *
           from sms_payment_vw
           where pbat_id = pb_id
           order by subsidy ASC,programme,beneficiary_name
      cursor cgref (low varchar2) is
           select *
           from cg_ref_codes
           where rv_domain ='SMS'
           and rv_low_value = low
      success boolean;     
      begin  
           set_application_property(cursor_style,'busy');
           appl_code := sms_global.ref_code('SMS','APP_CODE','SMS',0);
        dir       := sms_global.ref_code('SMS','PAY_DIR','c:\sms\batch_payments',0);
             success := webutil_file.create_directory(dir);
         if webutil_file.file_is_directory(dir) then
             null;
    --         message ('directory exists');
        else
    --                  message ('create directory ');
             success := webutil_file.create_directory(dir);
    --         if success then        message ('directory exists');    end if;
        end if;     
        for c_pbat in pbat loop
             file_name1 := dir ||'\' || appl_code||c_pbat.batch_number||'-'||to_char(c_pbat.batch_dt,'yyyymmdd')||'pay.txt';
             file_name2 := dir ||'\' || appl_code||c_pbat.batch_number||'-'||to_char(c_pbat.batch_dt,'yyyymmdd')||'merge.txt';
    --message('create files ');
    --         fil1  := client_text_io.fopen (file_name1,'W');
    --         fil2  := client_text_io.fopen (file_name2,'W');
        fil1  := client_text_io.fopen (file_name1,'W','');
        fil2  := client_text_io.fopen (file_name2,'W','');
                   dat :=                       'FROM ACCOUNT NUMBER'
                                                                ||'~'||'FROM ACCOUNT DESCRIPTION'
                                                                ||'~'||'MY STATEMENT DESCRIPTION'
                                                                ||'~'||'BENEFICIARY ACCOUNT NUMBER'
                                                                ||'~'||'BENEFICIARY SUB ACCOUNT NUMBER'        
                                                                ||'~'||'BENEFICIARY BRANCH CODE'
                                                                ||'~'||'BENEFICIARY NAME'
                                                                ||'~'||'BENEFICIARY STATEMENT DESCRIPTION'
                                                                ||'~'||'AMOUNT';
             --     client_text_io.put_line(fil1,dat);
             bvspro:= null;
             ssch  := null;
             cnt := 0;     
             dat := '~'||lpad('~',16,'~');
             for c_pay in pay(c_pbat.id) loop
    --message('cpay loop ' || cnt);              
               if bvspro is null then
                     dat := lpad('~',16,'~');
                     dat := utility.put_field(1,c_pay.programme,dat,'~');     
               client_text_io.put_line(fil2,dat);
               dat := utility.put_field(1,c_pay.subsidy,dat,'~');
               client_text_io.put_line(fil2,dat);
               dat := merge_header3;
                     client_text_io.put_line(fil2,dat);
                     bvspro := c_pay.programme;
                     ssch := c_pay.subsidy;
                     grand_total := 0;
                     bvspro_total := 0;
                     ssch_total := 0;
               end if;
               if bvspro <> c_pay.programme then
                     dat := lpad('~',16,'~');
                     dat := utility.put_field(5,ssch_total,dat,'~');
                     dat := lpad('~',16,'~');
                     dat := utility.put_field(5,bvspro_total,dat,'~');
               dat := utility.put_field(1,'Total:' || bvspro,dat,'~');
                     client_text_io.put_line(fil2,dat);
                     dat := lpad('~',16,'~');
               client_text_io.put_line(fil2,dat);
                     dat := utility.put_field(1,c_pay.programme,dat,'~');     
               client_text_io.put_line(fil2,dat);
                     bvspro := c_pay.programme;
               dat := utility.put_field(1,c_pay.subsidy,dat,'~');
               client_text_io.put_line(fil2,dat);
               dat := merge_header3;
                     client_text_io.put_line(fil2,dat);
                     bvspro := c_pay.programme;
                     ssch := c_pay.subsidy;
                     bvspro_total := 0;
                     ssch_total := 0;
                     cnt :=0;
             end if;                           
               if ssch <> c_pay.subsidy then
                     dat := lpad('~',16,'~');
                     dat := utility.put_field(5,ssch_total,dat,'~');
                     dat := lpad('~',16,'~');
               client_text_io.put_line(fil2,dat);
               dat := utility.put_field(1,c_pay.subsidy,dat,'~');
               client_text_io.put_line(fil2,dat);
               dat := merge_header3;
                     client_text_io.put_line(fil2,dat);
                     ssch := c_pay.subsidy;
                     ssch_total := 0;
                     cnt :=0;
             end if;                           
            bvspro_total := bvspro_total + c_pay.amount;
            ssch_total   := ssch_total   + c_pay.amount;              
                  grand_total  := grand_total  + c_pay.amount;              
            cnt := cnt +1;
    --message('bfore write file 2 ' );              
            client_text_io.put_line(fil2
                                   ,cnt
                            ||'~'|| c_pay.beneficiary_name
                                                                ||'~'||c_pay.BENEFICIARY_ACCOUNT_NUMBER ||''            
                                                                ||'~'||c_pay.BRANCH_CODE             ||''           
                                                                ||'~'|| c_pay.BENEFICIARY_STATEMENT_DESC            
                                                                ||'~'|| c_pay.AMOUNT                                
                            ||'~'|| c_pay.address_line1
                            ||'~'|| c_pay.address_line2
                                                    ||'~'|| c_pay.postal_code
                                                    ||'~'|| TO_CHAR(c_pay.deposit_date,'DD-Mon-YYYY')
                                                    ||'~'|| c_pay.month
                                                    ||'~'|| c_pay.bank
                                                    ||'~'|| c_pay.bank_branch
                                                    ||'~'|| c_pay.account_type
                                                    ||'~'|| c_pay.subsidy
                                                    ||'~'|| c_pay.programme)
                  DATA :=                                  c_pay.FROM_ACCOUNT_NUMBER                   
                                                                ||'~'||c_pay.FROM_ACCOUNT_DESCR                    
                                                                ||'~'||c_pay.MY_STATEMENT_DESCR                    
                                                                ||'~'||c_pay.BENEFICIARY_ACCOUNT_NUMBER
                                                                ||'~'
                                                                ||'~'||c_pay.BRANCH_CODE            
                                                                ||'~'||c_pay.BENEFICIARY_NAME                      
                                                                ||'~'||c_pay.BENEFICIARY_STATEMENT_DESC            
                                                                ||'~'||c_pay.AMOUNT;                                
            DATA := REPLACE(DATA, ',' , ' ' );
            DATA := REPLACE(DATA, '~' , ',' );
    --message (cnt ||' ' || data);       
    --message('bfore write file 1 ' );              
                  client_text_io.put_line(fil1, data);
             end loop;
    --message ('end of write');         
                 dat := lpad('~',16,'~');
                 dat := utility.put_field(6,ssch_total,dat,'~');
                 dat := lpad('~',16,'~');
           dat := utility.put_field(1,'Total:' || bvspro,dat,'~');
                 dat := utility.put_field(5,bvspro_total,dat,'~');
              client_text_io.put_line(fil2,dat);
              dat := lpad('~',16,'~');
           client_text_io.put_line(fil2,dat);
           dat := utility.put_field(1,'Grand Total:' ,dat,'~');
                 dat := utility.put_field(5,grand_total,dat,'~');
              client_text_io.put_line(fil2,dat);
             -- close file
    for i in 1..50 loop  
           if substr(i,-1) = 0 then
                 message ('flush ' || i);
           end if;                 
                  client_text_io.put_line(fil1, lpad(' ',2000));
                  client_text_io.put_line(fil2, lpad(' ',2000));
                  client_text_io.put_line(fil1, lpad(' ',2000));
                  client_text_io.put_line(fil2, lpad(' ',2000));
    end loop;
             client_text_io.fclose(fil1);
             client_text_io.fclose(fil2);
        end loop;
       set_application_property(cursor_style,'default');
        exception
             when others then
                  message(sqlcode ||' ' ||sqlerrm);
       end download_file;    i try this but this code onlydownload image not data from database tables
        public void downloadImage(FacesContext facesContext, OutputStream outputStream)
            BindingContainer bindings = BindingContext.getCurrent().getCurrentBindingsEntry();
            // get an ADF attributevalue from the ADF page definitions
            AttributeBinding attr = (AttributeBinding) bindings.getControlBinding("DocumentImage");
            if (attr == null)
                return;
            // the value is a BlobDomain data type
            BlobDomain blob = (BlobDomain) attr.getInputValue();
            try
            {   // copy the data from the BlobDomain to the output stream
                IOUtils.copy(blob.getInputStream(), outputStream);
                // cloase the blob to release the recources
                blob.closeInputStream();
                // flush the output stream
                outputStream.flush();
            catch (IOException e)
                // handle errors
                e.printStackTrace();
                FacesMessage msg = new FacesMessage(FacesMessage.SEVERITY_ERROR, e.getMessage(), "");
                FacesContext.getCurrentInstance().addMessage(null, msg);
            }

    You should ask your forum in the ADF-forum.

  • Does ODI has ability to extract data from multiple tables

    We have requirement using ODI to extract data from multiple tables depending on certain logic and spool 100+ files.
    How efficient ODI is in data extraction from several multiple tables especially when the extraction is dependent on certain business logic conditions ? Also, if anyone used Peoplesoft Application Engine process to extract volumes of data, how efficient Peoplesoft Applicaiton Engine process is as compared to ODI ? I will really appreciate if someone throws some light on this ? Thanks in advance.
    Ram

    One more option
    Create two Integration Interfaces and launch them sequentially:
    1st Interface : select a IKM ... Append and activate the Distinct rows check box.
    2nd Interface : select an IKM ... Incremental Update and set the UPDATE option to No.
    Be aware that the update key in this Integration Interface should be composed of all the target columns mapped. Also activate the Distinct rows check box.
    Thanks,
    Sutirtha
    Edited by: Sutirtha Roy on Jul 21, 2009 10:08 AM

  • Extracting data from multiple tables using DB connect

    Hi,
       I am having different tables which are  having the same structure in oracle database but  there names are different.Now i have only one datasource at BI side.This datasource shld extract data from the  tables dynamically.How can i do it using DB Connect .
    Thnxs

    ahh I see - problem as you said then is if you then take on a new location!
    I would then put into the source system a table identifier and create a view across all the tables
    Then dbconnect from the view and use the selection parameter of table parameter if you wanted one infopackage per "location"
    If you do need to have a new table in the source then just expand the view and create a new ipak
    hence NO bw changes required that need a dev-q-p transport - just the ipak in prod and it;s the source systems problem to add the extra table to the view

  • How can i extract data from oracle table  to flat file or excel spread shee

    Hello,
    DB Version is 10.1.0.3.0
    How can i extract data from oracle table to flat file or excel spread sheet by using sub programs?
    Regards,
    D

    Here what I did
    SET NEWPAGE 0
    SET SPACE 0
    SET LINESIZE 80
    SET PAGESIZE 0
    SET ECHO OFF
    SET FEEDBACK OFF
    SET VERIFY OFF
    SET HEADING OFF
    SET MARKUP HTML OFF SPOOL OFF
    Sql> SPOOL bing
    select * from -------;
    SPOOL OFF;
    I do not see file.
    I also tried
    Sql> SPOOL /tmp/bing
    select * from -------;
    SPOOL OFF;
    But still not seeing the fie,

  • To extract Data from Pool Table Data Sources

    hi
    I want to extract data from Pool table, for that i want to create infoset for that pool table. can anyone please let me know the
    procedure to create info set on pool tables.
    Regards
    Atul
    Moderator message: please (re)search yourself first.
    Edited by: Thomas Zloch on Nov 8, 2010 12:54 PM

    Hi Atul
    You have a couple of options here:
    1) Create Infoset SQ02 on those tables and RSO2 - create generic ds
    2) Create functional Module and create generic ds using FM
    Replicate DS to BW and Build objects and map them in transformations and create dtp and IP.
    Refer to this [link|How to extract data from a pool table?; for more details.
    Regards
    Harsh

  • Extracting data from Z-table from SAP R/3 to BW

    Hi all
    I want to extract data from a Z-table from SAP R/3 system to Bw system. Currently I am on BW 3.5. Since it is a Z table I dont have a standard extractor for it & I dont knw how to create it. Can anyone provide me with the step-by-step documentation of how to extract data from a non standard SAP table????

    Hi
    You need to create Generic Datasource on the Z-Table you want to get data from
    Go to RSO2 transaction to create generic datasource .
    You need to give technical name of datasource under datasource type you want and click on create. Then you can give descrption and Application component under which u want see the datasource,
    enter the z table name under view/ table and save.
    here you can click on check boxes to make fields hidden or selection fields.
    Regards
    Ravi
    Edited by: Ravi Naalla on Aug 25, 2009 8:24 AM

  • How to Extract data from Cluster table  and transperant table

    Hello BW Experts ,
    I want to extract the data from cluster table BSEG and a transperant table BKPF .
    The primary fields are BELNR , GJHAR and BUKRS.
    the fields of table BKPF to extarct is BUDAT and fields of BSEG table is HKONT , BSCHL , ZUONR and POSID.
    I can not create a view over these two tables as BSEG is a Cluster table.
    Please guide me.
    Regadrs ,
    Amol.

    hi Amol,
    take a look Sigg's weblog
    /people/siegfried.szameitat/blog/2005/09/29/generic-extraction-via-function-module
    you can use RSAX_BIW_GET_DATA_SIMPLE as sample, there specified import parameters
    FUNCTION RSAX_BIW_GET_DATA_SIMPLE.
    ""Lokale Schnittstelle:
    *" IMPORTING
    *" VALUE(I_REQUNR) TYPE SRSC_S_IF_SIMPLE-REQUNR
    *" VALUE(I_DSOURCE) TYPE SRSC_S_IF_SIMPLE-DSOURCE OPTIONAL
    *" VALUE(I_MAXSIZE) TYPE SRSC_S_IF_SIMPLE-MAXSIZE OPTIONAL
    *" VALUE(I_INITFLAG) TYPE SRSC_S_IF_SIMPLE-INITFLAG OPTIONAL
    *" VALUE(I_READ_ONLY) TYPE SRSC_S_IF_SIMPLE-READONLY OPTIONAL
    *" TABLES
    *" I_T_SELECT TYPE SRSC_S_IF_SIMPLE-T_SELECT OPTIONAL
    *" I_T_FIELDS TYPE SRSC_S_IF_SIMPLE-T_FIELDS OPTIONAL
    *" E_T_DATA STRUCTURE SFLIGHT OPTIONAL
    *" EXCEPTIONS
    *" NO_MORE_DATA
    *" ERROR_PASSED_TO_MESS_HANDLER

  • Need suggestion on how to extract data from a table

    Many years ago, I wrote many Perl scripts to increase my work productivity.
    Now I am starting learning Java, Javascript and PHP for some purposes. Just wrote a simple html2txt java program.
    Now I need experts' suggestion for one specific purpose - extract data from a html table. One of the examples is here: http://mops.tse.com.tw/nas/t06sa18/200902/A02_2454_200902.htm
    I need to extract datum from the table and make some analysis. (Txt is in Chinese, sorry)
    What is the best way to code it? Java, PHP or other? If Java, any suggestion what classes/module and approach to use?
    Thanks very much.

    xcomme wrote:
    Many years ago, I wrote many Perl scripts to increase my work productivity.
    Now I am starting learning Java, Javascript and PHP for some purposes. Just wrote a simple html2txt java program.
    Now I need experts' suggestion for one specific purpose - extract data from a html table. One of the examples is here: http://mops.tse.com.tw/nas/t06sa18/200902/A02_2454_200902.htm
    I need to extract datum from the table and make some analysis. (Txt is in Chinese, sorry)
    What is the best way to code it? It this a one shot (one time only task)? Then the best way is whatever way you are most comfortable with and which works.
    If on going then I doubt language choice matters but using a html parser rather than attempting to parse it yourself is going to help in any language.
    And are you starting with html files or starting with a http server? The two are very different.

  • Extracting Data From a Table in Oracle

    How would one extract the data from a table in oracle and put in ascii format file?
    Do you use sql loader?

    http://asktom.oracle.com/pls/ask/f?p=4950:8:6139291395251309702::NO::F4950_P8_DISPLAYID,F4950_P8_CRITERIA:68212348056,
    http://asktom.oracle.com/pls/ask/f?p=4950:8:::::F4950_P8_DISPLAYID:464420312302

Maybe you are looking for