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3MANBOXIDSERIAL
MANDT
X
Z3MANBOXIDSERIAL
WERKS
X
Z3MANBOXIDSERIAL
EXIDV
X
Z3MANBOXIDSERIAL
ZMANNO
X
Z3MANBOXIDSERIAL
ITEM_NO
Z3MANBOXIDSERIAL
SERNR
Based on all the above tables i need to fill in below internal table field as given below:
<b>Internal Table I_TAB
ZMANNO
LGNUM
WERKS
EXIDV
ITEM_NO
MATNR
SERNR
VEMNG
VEMEH
VLTYP
NLTYP
VLPLA
NLPLA
ZLOAD
USNAM
STATUS
BUDAT
CPUTM
ZINDAT
ZINTIM
ZARDAT
ZARTIM
ZCLDAT
ZCLTIM</b>
Extract data from Manifest header <b>Z0MNH, Z3MANBOXIDHDR,
Z3MANBOXIDITM, Z3MANBOXIDSER and LTAP</b> tables based on selection parameter.
Selection Screen will have folowing Select-option fields-
<b>LGNUM
WERKS
ZMANNO
USNAM
ZLOAD
EXIDV
MATNR
SERNR
VLTYP
NLTYP
VLPLA
NLPLA
BUDAT
ZINDAT
ZARDAT
ZCLDAT</b>
Based on above selection criteria i need to fetch above internal table fields data.
Then need to Move corresponding header and item data in ITAB_RESULT internal table.
I need to fetch above fields based on above 5 tables and put in final Internal Table.
Can anybody tell me the logic how can i write the same.
Also can anybody tell me i am trying to create a DataBaseView for
Z0MNH, Z3MANBOXIDHDR, Z3MANBOXIDITM, Z3MANBOXIDSERIAL and LTAP tables.
<b>Note:
1. Z3MANBOXIDITM table may contain multiple material[MATNR] for same box-id[EXIDV] (with another line item).
2.  Z3MANBOXIDSERIAL table may contain multiple record for one box id[EXIDV]+item_no[ITEM_NO].</b>
But what are the <b>TABLE/JOIN Conditions</b> i need to write while creating <b>DB View</b> for above <b>5</b> tables.
Can anybody solve above 2 issues!
Thanks in advance.
Thanks,
Deep.

Hi Deep,
While creation of DB view just make sure abt the key relation between the tables. Based on that u can join the tables...First fetch the data from header table then by using for all entries u can fetch the line items data.
Hope this helps you. Reply for queries, shall post the updates.
Regards. 
Kumar.

Similar Messages

  • How to fetch data for a struture from a cluster table

    How can I fetch data for a struture, from a cluster table, based on the name of the structure?

    Hi,
    In order to read from Cluster DB Table use the following statement:
    Syntax
    IMPORT <f1> [ TO  < g1 > ] <f2> [TO < g2 >] ...
    FROM DATABASE <dbtab>(<ar>)
    [CLIENT <cli>] ID <key>|MAJOR-ID <maid> [MINOR-ID <miid>].
    This statement reads the data objects specified in the list from a cluster in the database <dbtab>.
    You must declare <dbtab> using a TABLES statement. If you do not use the TO <gi> option, the
    data object <fi> in the database is assigned to the data object in the program with the same
    name. If you do use the option, the data object <fi> is read from the database into the field <gi>.
    For <ar>, enter the two-character area ID for the cluster in the database. The name <key>
    identifies the data in the database. Its maximum length depends on the length of the name field
    in <dbtab>.
    The CLIENT <cli> option allows you to disable the automatic client handling of a client-specific cluster database, and specify the client yourself. The addition must always come directly after the name of the database.
    For Eg:
    PROGRAM SAPMZTS3.
    TABLES INDX.
    DATA: BEGIN OF JTAB OCCURS 100,
    COL1 TYPE I,
    COL2 TYPE I,
    END OF JTAB.
    IMPORT ITAB TO JTAB FROM DATABASE INDX(HK) ID 'Table'.
    WRITE: / 'AEDAT:', INDX-AEDAT,
    / 'USERA:', INDX-USERA,
    / 'PGMID:', INDX-PGMID.
    SKIP.
    WRITE 'JTAB:'.
    LOOP AT JTAB FROM 1 TO 5.
    WRITE: / JTAB-COL1, JTAB-COL2.
    ENDLOOP.
    Regards,
    Neha
    Edited by: Neha Shukla on Mar 12, 2009 1:35 PM

  • HOW TO INSERT DATA INTO SQL SERVER FROM MS ACCESS TABLE??

    NEED TO INSERT DATA INTO SQL SERVER FROM MS ACCESS TABLE.

    this is another method
    http://www.mssqltips.com/sqlservertip/2484/import-data-from-microsoft-access-to-sql-server/
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

  • Fetch data into internal table

    Hi all,
    I want to fetch all the opbel records from erdk table into an intrnal table.
    Only opbel records.There are 100000000 records in erdk table.
    How can I fetch into internal table ? what statement can I use to fetch the data faster keepin performance into consideration ?
    Many thanks

    Hi,
    As far as data fetch is concerned you do the same as follows:
    Select * from erdk into table itab
    where..... < Your Where Condition if any>.
    But as the number of records are very high, first try to put all the primary keys in the where clause and also if possible, try to narrow down the selection criteria by fetching data from some other table or widening the conditions in where clause.
    Also try to fetch only thode fields which you actually need.
    else your program will give performance problems.
    Hope this helps!
    Regards,
    Lalit

  • I want to insert data into a gta from a nested table

    Hi,
    I want to insert data into a global temporary table from nested table.
    How do i do it?

      cursor cc is select * from t1;
       TYPE temp_rec_tab IS TABLE OF temp_rec_tap_cur%ROWTYPE;
       TYPE rec_num_tab1 is table of temp_records_tap.record_num%type;
       v_test_tab     temp_rec_tab;
    ----   v_rec_num      num_tab;
       v_rec_num rec_num_tab1;  
       v_filename     temp_records_tap.file_name%TYPE;
       v_error_code   tap_reject.ERROR_CODE%TYPE;
       v_rej_value    tap_reject.field_rej%TYPE;
       v_count        NUMBER;
    BEGIN
       OPEN cc;
       LOOP
          BEGIN
             FETCH cc
             BULK COLLECT INTO v_test_tab LIMIT 1000;
             FORALL i IN v_test_tab.FIRST .. v_test_tab.LAST SAVE EXCEPTIONS
                INSERT INTO tt2
                     VALUES v_test_tab (i)
                  RETURNING       record_num
                BULK COLLECT INTO v_rec_num;
          EXCEPTION
             WHEN OTHERS
             THEN
          NULL;
          END;
          EXIT WHEN temp_rec_tap_cur%NOTFOUND;
       FORALL i in  v_rec_num.first..v_rec_num.last
       INSERT INTO record_num_session values v_rec_num(i); ------- v_num(i) INVALID IDENTIFIER ??????
       END LOOP;
    END;

  • Inserting data into a column from 2 different tables

    Hi,
    I need to insert data into a table using 2 other tables. The tables that contain data have identical column names.
    Is using a UNION statement the only option?
    Also, if I need to insert data into columns from only one of the either tables, how do i do it?
    Thanks.

    For future reference, "doesn't seem to work" is a rather generic description... Posting the particular error message will be quite helpful, though I'm reasonably confident that I know the particular problem here.
    First, if only for sanity, you probably want to explicitly list the columns of the destination table in your INSERT statement.
    Second, it doesn't make sense to have DISTINCT clauses in queries that are UNION-ed together. A UNION has to do a sort to remove duplicates already.
    Third, the two queries you are UNIONing together have to return the same number of columns, with the same names, in the same order.
    You probably want something like
    INSERT INTO new_table( col1, col2, col3, col4, col5 )
      SELECT 'ABC'  col1,
             a.colA col2,
             a.colB col3,
             a.colC col4
             a.colD col5
        FROM table1 a
      UNION
      SELECT 'ABC'  col1,
             b.colA col2,
             b.colB col3,
             b.colC col4
             NULL   col5
        FROM table2 bJustin
    Distributed Database Consulting, Inc.
    http://www.ddbcinc.com/askDDBC

  • How to Fetch Data into internal table column wise?

    The internal table contains huge set of data. Normally we fetch the data row wise using insert and select statements in work area.
    But, the requirement is on fetching the data column wise for each field from the database.
    So,can anyone help me on this issue for fetching the data column wise?

    Welcome to SDN.
    What you want to do(if I understand correctly) is not possible with the statements available to us.  You could do it, but I think it would be a lot of code and I don't think that its worth it.  Why exactly do you want to do this?
    Regards,
    Rich Heilman

  • Problem in collecting Spool data into internal table

    Hi ,
    i need to download  spool request data into internal table,
    after collecting i need to loop it and delete some records,
    for this i am using  Fm  RSPO_RETURN_ABAP_SPOOLJOB
    but getting some extra spaces and lines,unable to get right format.
    please help me in this issue to prepare internal table like normal internal table with spool id.
    Regards
    sarath

    Hi ,
    Thanks for the reply,
    My requirement is like i need to collect all the records from the spool to Internal table and
    after that based on one field in the internal table i have to separate error records by deleting sucess records from that internal table(from spool),
    for that i have to loop the internal table and need to count the error records, after that download to excel and mail functionalities
    required for that .
    so please help me in this.
    Regards
    sarath

  • Uploading  Excel sheet  data into internal table

    Hi All,
    I want to upload Excel file data into internal table. My problem is that my excel file  having more than one sheets. I want to upload  the data of particula Excel sheet..
    Please suggest me how can I upload particulat Excel sheet data .
    Thanks and regards
    Praveen

    check this link
    Uploading multiple excel sheets
    You can check Satish's answer in the above link
    Re: uploading data from excel sheets through BDC's into sap system
    <b>Award points if found helpful</b>

  • Char data into internal table.

    Hi all,
    I will get data from the FTP (.TXT file) through FTP_SERVER_TO_R3.
    in chardata with separater Tab delimited.
    here i took one field symbol and assigning the data into internal table.
    till here every thing is ok.
    My problem is one data type is 13 char, if that field is more than 13 char in the file
    it is giving DUMP. (DUMP is OVERFLOW Field 999976767878.22)
    TYPES : BEGIN OF X_STRING,
                       LINE(150) TYPE STRING,
                  END OF X_STRING.
    data : IT_STRING TYPE STANDARD TABLE OF X_STRING,
              WA_STRING TYPE X_STRING.
                          FIELD-SYMBOLS : <fs> TYPE ANY.
                        LOOP AT chardata INTO wa_chardata.
                          REFRESH it_string.
                          SPLIT wa_chardataline AT cl_abap_char_utilities=>horizontal_tab INTO TABLE it_string.
                          LOOP AT it_string INTO wa_string FROM 1 TO 29.
                            ASSIGN COMPONENT sy-tabix OF STRUCTURE wa_data TO <fs>.
                            <fs> = wa_string-field1.
                            UNASSIGN <fs>.
                          ENDLOOP.
                          APPEND wa_data TO it_data.
                          CLEAR wa_data.
                        ENDLOOP.
    Please give me solution to over come this.
    Regards,
    Sri

    In Statement ASSIGN COMPONENT sy-tabix OF STRUCTURE wa_data TO <fs>.
    insted of using SY-TABIX  use the actual field name of the structre wa_data .
    Use a RTTS Method to get all the fields of the structre WA_DATA and then loop at all the fields and then manuplate teh that which has been splitted...!
    Hope it helps it will not cause any over flow..and ...( Try to condence the The splitted dat use condence addition while moveing the data to wa_data it will avoide the leading and trailing spaces.... )
    Edited by: Anup Deshmukh on Jun 17, 2010 8:31 AM

  • How to load text data into internal table

    I have a text file to load txt data into internal table. So how to read text data with validation and to load all text data into the internal table?
    Say this is the text file:
    IO_NAME, IO_TYPE, IO_SHTXT, IO_LONGTEXT, DATATYPE, DATA LENGTH
    ZIO_TEST1, CHA,      IO TEST1,      IO TEST 1,        CHAR,         20
    ZIO_TEST2, CHA,      IO TEST2,      IO TEST 2,        CHAR,         20
    Regards,
    Mau

    Hi,
    U can use GUI_UPLOAD for this...
    Declare an internal table like
    data: begin of itab occurs 0,
    string(1200),
    end of itab.
    check the sample code:
    cange as you need
    DATA: DATEI_PC TYPE STRING VALUE 'C:\MATNR.TXT'.
    DATA: BEGIN OF ITAB occurs 0,
    TXT(1024),
    END OF ITAB.
    CALL METHOD CL_GUI_FRONTEND_SERVICES=>GUI_UPLOAD
    EXPORTING
    FILENAME = DATEI_PC
    FILETYPE = 'ASC'
    CHANGING
    DATA_TAB = ITAB[]
    EXCEPTIONS
    FILE_OPEN_ERROR = 1
    FILE_READ_ERROR = 2
    NO_BATCH = 3
    GUI_REFUSE_FILETRANSFER = 4
    INVALID_TYPE = 5
    NO_AUTHORITY = 6
    UNKNOWN_ERROR = 7
    BAD_DATA_FORMAT = 8
    HEADER_NOT_ALLOWED = 9
    SEPARATOR_NOT_ALLOWED = 10
    HEADER_TOO_LONG = 11
    UNKNOWN_DP_ERROR = 12
    ACCESS_DENIED = 13
    DP_OUT_OF_MEMORY = 14
    DISK_FULL = 15
    DP_TIMEOUT = 16
    NOT_SUPPORTED_BY_GUI = 17
    ERROR_NO_GUI = 18
    OTHERS = 19.
    IF SY-SUBRC NE 0. WRITE: / 'Error in Uploading'. STOP. ENDIF.
    WRITE: / 'UPLOAD:'.
    LOOP AT ITAB. WRITE: / ITAB-TXT. ENDLOOP.

  • Loading Text data into internal table

    I have a text file to load txt data into internal table. So how to read text data with validation and to load all text data into the internal table?
    Say this is the text file:
    IO_NAME, IO_TYPE, IO_SHTXT, IO_LONGTEXT, DATATYPE, DATA LENGTH
    ZIO_TEST1, CHA, IO TEST1, IO TEST 1, CHAR, 20
    ZIO_TEST2, CHA, IO TEST2, IO TEST 2, CHAR, 20
    Regards,
    Mau

    hi Mau,
    look this code, maybe it's help u.
    <b>REPORT  ZTXTTOTABLE.</b>
    DATA: p_file   TYPE string value 'C:\teste.txt',
          BEGIN OF TI_table OCCURS 0,
            COD(5) TYPE C,
            NAME(40),
          END OF TI_table,
          a(2).
    PARAMETERS: sel_file(128) TYPE c
                default 'C:\teste.txt' OBLIGATORY LOWER CASE.
    p_file = sel_file.
    CALL FUNCTION 'GUI_UPLOAD'
      EXPORTING
        filename = p_file
      TABLES
        data_tab = ti_table[].
    format color COL_TOTAL INTENSIFIED ON.
    loop at ti_table.
      write: / sy-vline, ti_table-cod, at 10 sy-vline, ti_table-name,
             at 60 sy-vline.
    endloop.
    write: / sy-uline(60).
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR sel_file.
      CALL FUNCTION 'WS_FILENAME_GET'
        EXPORTING
          def_filename     = ''
          def_path         = 'C:\'
          mask             = ',Documentos de texto (*.txt), *.txt.'
          mode             = ''
        IMPORTING
          filename         = p_file
        EXCEPTIONS
          inv_winsys       = 1
          no_batch         = 2
          selection_cancel = 3
          selection_error  = 4
          OTHERS           = 5.
      find '.txt' IN p_file.
      if sy-subrc <> 0.
        concatenate p_file '.txt' into sel_file.
      else.
        sel_file = p_file.
      endif.
    top-of-page.
      format color COL_HEADING INTENSIFIED ON.
      uline (60).
      write: / sy-vline, 'COD', at 10 sy-vline, 'NAME', at 60 sy-vline.
      write: / sy-uline(60).
    good luck!
    Regards
    Allan Cristian

  • Extract the classification data into internal table

    Hi all,
    I having requirement to extract classification data for material number.
    1) Provide the selection option for material number (MATNR).
    2) Based on the material number, then extract all that data into internal table as below layout. My problem is how to retrieve the following data from different table based on the MATNR (material number).
    Please provide the sample code for select the following data. Thanks.
    Classification table
    OBJEK  (from AUSP table)
    MAFID (from AUSP table)
    KLART (from AUSP table)
    CLASS  (from KLAH table)
    ATWRT (from AUSP table)
    MSEHI  (from CABN table)
    OBTAB (check if class type=002, set it as “MARA”)
    STDCL (from KSSK table)

    Hi,
    if I understand, you´re trying to get information from the classification system for the material. You can use the following code:
    DATA: clases LIKE TABLE OF sclass WITH HEADER LINE,
          datos LIKE TABLE OF clobjdat WITH HEADER LINE.
    CALL FUNCTION 'CLAF_CLASSIFICATION_OF_OBJECTS'
         EXPORTING
              class              = 'DESK'               "clase a buscar
              classtype          = '001'                "tipo de la clase
              features           = 'X'
              language           = sy-langu
              object             = 'PM00A000C055'       "Material
              objecttable        = 'MARA'
              key_date           = sy-datum
              initial_charact    = 'X'
              change_service_clf = 'X'
         TABLES
              t_class            = clases
              t_objectdata       = datos
         EXCEPTIONS
              no_classification  = 1
              no_classtypes      = 2
              invalid_class_type = 3
              OTHERS             = 4.
    loop at datos.
    endloop.

  • Upload excel data into Internal table

    Hi,
    I'm trying to upload excel data into internal table, well the excel file layout will be different on each run of the report.
    Excel file will have 60 columns and 500 record limit. I can upload the excel data using 'ALSM_EXCEL_TO_INTERNAL_TABLE' and 'KCD_EXCEL_OLE_TO_INT_CONVERT' but the output table is generates 60 lines for each record i.e.., 60 * 500 = 30,000 which could cause performance.
    I try with the FM 'TEXT_CONVERT_XLS_TO_SAP', but this will only work if the file structure is static. It didn't work for dynamic file layout. Even GUI_UPLOAD doesn't work to upload excel file, it will work if I convert the file to Tab delimited file.
    Please advise if you know any alternate procedure to upload excel data into internal table.
    Thanks,
    Kumar.

    Moderator message - Cross post locked
    Rob

  • Insert data into fact table from source database tables

    here i try to insert data into fact table from source database tables here is the query 
    ALTER procedure [dbo].[facttable]
    as
    insert into [pp dw].dbo.Dimfact(Prod_ID,Production_ID,Material_ID,Equip_ID,WC_ID,Recipe_ID,Quantity,costprice)
    select Products.[Product ID],[Production ID],Materials.[Material ID],[Equipment ID],[Work Centre ID],[Recipy ID],Quantity,[cost price]
    from
    [PRODUCTION PLANNING 2].dbo.[Products],
    [PRODUCTION PLANNING 2].dbo.[Production Detail],
    [PRODUCTION PLANNING 2].dbo.[Material category],
    [PRODUCTION PLANNING 2].dbo.[Materials],
    [PRODUCTION PLANNING 2].dbo.[Equipment],
    [PRODUCTION PLANNING 2].dbo.[Working Centre] ,
    [PRODUCTION PLANNING 2].dbo.[Recipies]
    where
    Products.[Product ID] in (13, 14, 15, 16, 17) and
    [Production Detail].[Production ID] in (1, 2, 3) and
    [Materials].[Material ID] in (1, 2, 3, 4, 5) and
    [Equipment].[Equipment ID] in (1, 2, 3, 4) and
    [Working Centre].[Work Centre ID] in (1, 2, 3) and
    [Recipies].[Recipy ID] in (1, 2, 3) and
    [Material category].[Category ID] in (8, 9, 10, 11, 12, 13)
    and when i execute query it shows me error 
    The INSERT statement conflicted with the FOREIGN KEY constraint "FK_Dimfact_Dimproduct". The conflict occurred in database "pp dw", table "dbo.Dimproduct", column 'Prod_ID'.
    ERD IS
    HOW TO SOLVE THIS PROBLEM?

    I cant see any join conditions in your query posted. Whats the purpose of the query above. It will just bring you a cartesian product (cross join) of tables involved subjected to filters. Are you sure this is the correct query?
    The error you're getting may be because you've not yet populated DimProduct or may be because of logic you used in popultaing DimProduct causing it to miss some records which is what query is referring to in above case.
    Please Mark This As Answer if it solved your issue
    Please Mark This As Helpful if it helps to solve your issue
    Visakh
    My MSDN Page
    My Personal Blog
    My Facebook Page

Maybe you are looking for

  • EDI: creating a sales order with reference to contract

    Dear gurus, we would like to create a sales order with reference to a SD contract from an ORDERS IDoc. OSS say we have to populate the E1EDx02 segments with the contract number to do this. We tested this in our system by manually editing the incoming

  • IPod Classic 120GB ejects every time its connected and found by iTunes.

    My iPod is about to drive me insane, I came home today and connected it to take a few songs off of it and change it so it wouldn't continue to sync my entire library. Upon doing so now every time I connect it it gets ejected before I can restore it b

  • Problem with Posting IDOC

    Hi, Hi, I am Integrating SAP R/3 and WebBrowser using XI. In SAP R/3 I am Using IE02( Change Equipment) ,When Ever we made a change in Equipment and save it should trigger automatically and post the IDOC to XI. I need the Infpirmation How to Trigger

  • Klammer - no permission to open winmail.dat files

    Up to now I have been able to open Winmail.dat files without a problem. Suddenly I get the response "Not permitted to open the file"; When I check the file in Finder I have the rights to read and wright. Here I am stuck. Would appreciate some advice.

  • How to Import One Library (contents) to a New Library ?

    I have my Aperture Library on Computer 1 ( the library is backed up via Vault on my External HD )( note: computer 1 is going back to the store ) I want Computer #2 to use the Library thats on the External HD ( the same library from computer 1 ) I kno