Comparing two internal tables and deleting the record not present in second

Hi All,
I have a internal table itaba with PERNR as primary key and various other columns (1000 records) and table B with PERNR as primary key and 800 records.
Now what is the best way to compare these two and delete the record from table A when its corresponding record is not present in table B?
Thanks and Regards,
Mohan

HI SIR
u trained us in accenture
Hi all
when ever m running this session in SM35 , M getting error as :
"LEAVE TO TRANSACTION" MARA-BISMT is not allow
in batch input
REPORT YASEC_BDC_NIK_SESSION
no standard page heading
message-id zmm
line-count 65
line-size 150.
tables : mara.
*Top includr program
INCLUDE YNEW_MAIN_TOP.
*include yasec_bdc_nik_session_top.
***********selection screen *******************
selection-screen begin of block b1 with frame title text-001.
selection-screen skip.
PARAMETERS: p_ifile(128) TYPE c .
SELECTION-SCREEN SKIP.
SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-002.
PARAMETERS: rad1 TYPE c RADIOBUTTON GROUP 1 USER-COMMAND gr1,
rad2 TYPE c RADIOBUTTON GROUP 1 .
SELECTION-SCREEN SKIP.
PARAMETERS: p_sess TYPE c.
SELECTION-SCREEN END OF BLOCK b2.
SELECTION-SCREEN SKIP.
SELECTION-SCREEN END OF BLOCK b1.
Subroutine call***************************
INCLUDE YNEW_MAIN_F01.
*include yasec_bdc_nik_session_f01.
*********At selection event triggered *************
at selection-screen on value-request for p_ifile.
To get F4 help for the input file path
PERFORM f_f4_input_file.
AT SELECTION-SCREEN ON p_ifile.
To validate and upload the input file
PERFORM f_load_file.
AT SELECTION-SCREEN ON p_sess.
To validate the Number of Sessions field
IF rad2 IS NOT INITIAL AND sy-ucomm EQ c_onli.
PERFORM f_check_sessions.
ENDIF.
***********Start of selection *******************
start-of-selection.
*To process BDC
PERFORM f_process_bdc.
TOP OF PAGE
TOP-OF-PAGE.
Writes the report heading and for displaying line number.
PERFORM f_report_header.
TYPES : BEGIN OF t_final,
matnr(50) TYPE c,
bismt(18) type c,
end of t_final.
TYPES: BEGIN OF t_fdata,
data(256) TYPE c,
END OF t_fdata.
TYPES: BEGIN OF t_error,
message(100) TYPE c,
END OF t_error.
*Internal table declarations
*Internal table to load the data from the file that is changed throgh BDC
DATA : i_final TYPE STANDARD TABLE OF t_final,
wa_final TYPE t_final.
*Internal table to store the error messages
DATA : i_error TYPE STANDARD TABLE OF t_error,
wa_error TYPE t_error.
*Internal table to load the raw data
DATA : i_fdata TYPE STANDARD TABLE OF t_fdata,
wa_fdata TYPE t_fdata.
*Internal table to store records of BDC
DATA : i_bdcdata TYPE STANDARD TABLE OF bdcdata INITIAL SIZE 0,
wa_bdcdata TYPE bdcdata.
Internal table to store BDC messages
DATA: i_bdcmsgcoll TYPE STANDARD TABLE OF bdcmsgcoll INITIAL SIZE 0,
wa_bdcmsgcoll TYPE bdcmsgcoll.
VARIABLE DECLARATIONS
DATA: v_ifile TYPE string,
v_input TYPE i,
c_delimiter TYPE c VALUE 'X',
v_mode TYPE c VALUE 'A',
v_sessions TYPE i.
CONSTANTS
CONSTANTS : c_flagx TYPE c VALUE 'X',
c_slash TYPE c VALUE '/',
c_onli(4) TYPE c VALUE 'ONLI',
c_vl02(4) TYPE c VALUE 'VL02',
c_s TYPE c VALUE 'A'.
FORM f_f4_input_file .
CALL FUNCTION 'F4_FILENAME'
EXPORTING
program_name = syst-cprog
dynpro_number = syst-dynnr
IMPORTING
file_name = p_ifile.
ENDFORM. " f_f4_input_file
*& Form f_load_file
FORM f_load_file .
v_ifile = p_ifile.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = v_ifile
filetype = 'ASC'
has_field_separator = 'X'
TABLES
data_tab = i_fdata
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
OTHERS = 17.
IF sy-subrc <> 0.
*Text-103-Input file does not exist.
MESSAGE e000 WITH text-103 .
ELSEIF NOT i_fdata IS INITIAL.
DELETE i_fdata WHERE data = space.
DESCRIBE TABLE i_fdata LINES v_input.
ENDIF.
IF v_input EQ 0.
Text-104 - Input file is empty.
MESSAGE e000 WITH text-104 .
ENDIF.
ENDFORM. " f_load_file
*& Form f_check_sessions
FORM f_check_sessions .
IF p_sess IS INITIAL.
MESSAGE e000 WITH text-106.
ELSE.
v_sessions = v_input DIV p_sess.
ENDIF.
ENDFORM. " f_check_sessions
*& Form f_process_bdc
text
FORM f_process_bdc.
LOOP AT i_fdata INTO wa_fdata.
SPLIT wa_fdata AT cl_abap_char_utilities=>horizontal_tab
INTO wa_final-matnr
wa_final-bismt.
APPEND wa_final TO i_final.
CLEAR wa_fdata.
ENDLOOP.
IF rad1 = c_flagx.
PERFORM f_passbdc_vl02.
ELSEIF rad2 = c_flagx.
PERFORM f_sessions_vl02.
ENDIF.
ENDFORM. "f_process_bdc
To populate the Screen information
p_program Program Name
p_dynpro Screen Number
FORM bdc_dynpro USING p_program TYPE any
p_dynpro TYPE any.
CLEAR wa_bdcdata.
Populate the BDC structure with the Screen Information.
Move the Program name PROGRAM
wa_bdcdata-program = p_program.
Move the Screen Number DYNPRO
wa_bdcdata-dynpro = p_dynpro.
Indicate the beginning of a new screen
wa_bdcdata-dynbegin = c_flagx.
APPEND wa_bdcdata TO i_bdcdata.
ENDFORM. "f_bdc_dynpro
*& Form f_passbdc_vl02
text
FORM f_passbdc_vl02.
DATA: l_lines_im TYPE i.
SORT i_final BY matnr ASCENDING.
CLEAR wa_final.
LOOP AT i_final INTO wa_final.
CLEAR: i_bdcmsgcoll[],
wa_bdcmsgcoll,
wa_bdcdata.
CLEAR: i_bdcdata[].
perform bdc_dynpro using 'SAPLMGMM' '0060'.
perform bdc_field using 'BDC_CURSOR'
'RMMG1-MATNR'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'RMMG1-MATNR'
wa_final-matnr.
perform bdc_dynpro using 'SAPLMGMM' '0070'.
perform bdc_field using 'BDC_CURSOR'
'MSICHTAUSW-DYTXT(01)'.
perform bdc_field using 'BDC_OKCODE'
'=ENTR'.
perform bdc_field using 'MSICHTAUSW-KZSEL(01)'
'X'.
perform bdc_dynpro using 'SAPLMGMM' '4004'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'BDC_CURSOR'
'MARA-BISMT'.
perform bdc_field using 'MARA-BISMT'
wa_final-bismt.
perform bdc_dynpro using 'SAPLSPO1' '0300'.
perform bdc_field using 'BDC_OKCODE'
'=YES'.
perform bdc_transaction using 'MM02'.
perform bdc_dynpro using 'SAPLMGMM' '0060'.
perform bdc_field using 'BDC_CURSOR'
'RMMG1-MATNR'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_dynpro using 'SAPLMGMM' '0070'.
perform bdc_field using 'BDC_CURSOR'
'MSICHTAUSW-DYTXT(01)'.
perform bdc_field using 'BDC_OKCODE'
'=ENTR'.
perform bdc_dynpro using 'SAPLMGMM' '4004'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'BDC_CURSOR'
'RMMG1-MATNR'.
perform bdc_dynpro using 'SAPLSPO1' '0300'.
perform bdc_field using 'BDC_OKCODE'
'=YES'.
perform bdc_transaction using 'MM03'.
CALL TRANSACTION 'MM02' USING i_bdcdata
MODE v_mode
UPDATE c_s
MESSAGES INTO i_bdcmsgcoll.
If error occurred in call transaction 'VA02' then stores all
information of failed records into internal table i_error_im.
IF sy-subrc NE 0.
DESCRIBE TABLE i_bdcmsgcoll LINES l_lines_im.
CLEAR wa_bdcmsgcoll.
READ TABLE i_bdcmsgcoll INTO wa_bdcmsgcoll INDEX l_lines_im.
To capture success and error messages in BDC.
CALL FUNCTION 'FORMAT_MESSAGE' "#EC *
EXPORTING
id = wa_bdcmsgcoll-msgid
lang = wa_bdcmsgcoll-msgspra
no = wa_bdcmsgcoll-msgnr
v1 = wa_bdcmsgcoll-msgv1
v2 = wa_bdcmsgcoll-msgv2
v3 = wa_bdcmsgcoll-msgv3
v4 = wa_bdcmsgcoll-msgv4
IMPORTING
msg = wa_error-message
EXCEPTIONS
not_found = 1
OTHERS = 2.
IF sy-subrc <> 0.
ENDIF.
ELSE.
WRITE: text-111 COLOR 7.
ENDIF.
CLEAR: wa_final.
REFRESH i_bdcdata.
ENDLOOP.
ENDFORM. "f_passbdc_va02
*& Form bdc_field
text
-->P_FNAM text
-->P_FVAL text
FORM bdc_field USING p_fnam TYPE any
p_fval TYPE any.
CLEAR wa_bdcdata.
Populate the Field Name
wa_bdcdata-fnam = p_fnam.
Populate the field value
wa_bdcdata-fval = p_fval.
APPEND wa_bdcdata TO i_bdcdata.
ENDFORM. "f_bdc_field
*& Form f_sessions_vl02
text
FORM f_sessions_vl02 .
DATA: l_sindex TYPE sy-tabix VALUE 1,
l_eindex TYPE sy-tabix,
l_flag TYPE c VALUE space.
l_eindex = v_input.
SORT i_final BY matnr ASCENDING.
DO p_sess TIMES.
CALL FUNCTION 'BDC_OPEN_GROUP'
EXPORTING
client = sy-mandt
group = 'Y_VL02_NIK'
user = sy-uname
keep = c_flagx
EXCEPTIONS
client_invalid = 1
destination_invalid = 2
group_invalid = 3
group_is_locked = 4
holddate_invalid = 5
internal_error = 6
queue_error = 7
running = 8
system_lock_error = 9
user_invalid = 10
OTHERS = 11.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
CLEAR wa_final.
CLEAR: i_bdcdata[].
LOOP AT i_final INTO wa_final FROM l_sindex TO l_eindex .
IF l_flag = v_sessions.
CLEAR l_flag.
EXIT.
ENDIF.
l_flag = l_flag + 1.
CLEAR: i_bdcdata[].
perform bdc_dynpro using 'SAPLMGMM' '0060'.
perform bdc_field using 'BDC_CURSOR'
'RMMG1-MATNR'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'RMMG1-MATNR'
wa_final-matnr.
perform bdc_dynpro using 'SAPLMGMM' '0070'.
perform bdc_field using 'BDC_CURSOR'
'MSICHTAUSW-DYTXT(01)'.
perform bdc_field using 'BDC_OKCODE'
'=ENTR'.
perform bdc_field using 'MSICHTAUSW-KZSEL(01)'
'X'.
perform bdc_dynpro using 'SAPLMGMM' '4004'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'BDC_CURSOR'
'MARA-BISMT'.
perform bdc_field using 'MARA-BISMT'
wa_final-bismt.
perform bdc_dynpro using 'SAPLSPO1' '0300'.
perform bdc_field using 'BDC_OKCODE'
'=YES'.
perform bdc_transaction using 'MM02'.
perform bdc_dynpro using 'SAPLMGMM' '0060'.
perform bdc_field using 'BDC_CURSOR'
'RMMG1-MATNR'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_dynpro using 'SAPLMGMM' '0070'.
perform bdc_field using 'BDC_CURSOR'
'MSICHTAUSW-DYTXT(01)'.
perform bdc_field using 'BDC_OKCODE'
'=ENTR'.
perform bdc_dynpro using 'SAPLMGMM' '4004'.
perform bdc_field using 'BDC_OKCODE'
'/00'.
perform bdc_field using 'BDC_CURSOR'
'RMMG1-MATNR'.
perform bdc_dynpro using 'SAPLSPO1' '0300'.
perform bdc_field using 'BDC_OKCODE'
'=YES'.
perform bdc_transaction using 'MM03'.
l_sindex = l_sindex + 1.
ENDLOOP.
CALL FUNCTION 'BDC_CLOSE_GROUP'
EXCEPTIONS
not_open = 1
queue_error = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDDO.
ENDFORM. " f_sessions_vl02
*& Form f_report_header
FORM f_report_header .
FORMAT COLOR COL_HEADING INTENSIFIED ON.
ULINE.
text-201 - Company: Carrier
text-102- Batch Data Communication.
text-202 - System: SAP
WRITE: /1 sy-vline,
3 text-201,
50 text-102,
100 text-202,
AT sy-linsz sy-vline.
text-203 - Program:
text-204 - Date/Time:
WRITE: /1 sy-vline,
3 text-203, sy-repid ,
100 text-204,sy-datum ,c_slash, sy-uzeit,
AT sy-linsz sy-vline.
text-205 - User ID:
text-206 - Page:
WRITE: /1 sy-vline,
3 text-205, sy-uname,
100 text-206, sy-pagno,
AT sy-linsz sy-vline.
FORMAT COLOR OFF.
ULINE.
ENDFORM. " f_report_header
FORM bdc_transaction USING tcode.
CALL FUNCTION 'BDC_INSERT'
EXPORTING
tcode = tcode
TABLES
dynprotab = i_bdcdata
EXCEPTIONS
internal_error = 1
not_open = 2
queue_error = 3
tcode_invalid = 4
printing_invalid = 5
posting_invalid = 6
OTHERS = 7.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ELSE.
WRITE: / text-109 ,wa_final-matnr,
text-110 .
ENDIF.
ENDFORM. "bdc_transaction

Similar Messages

  • To compare two internal tables and delete records

    Hi friends,
        I have to compare two internal tables and should delete the records which is not present in both the tables. Reply me as soon as possible.
    Thanks.

    Hi Nagarajan,
    1. I don't think there is any direct (one-shot statement)
        way to achieve this.
        one has to do by writing some logic.
    2. Loop at ITAB1.
         Read table ITAB2 with key Field1 = ITAB1-Field1.
         If sy-subrc <> 0.
         delete ITAB1.
         endif.
       Endloop.
      Do the same again with ITAB2.
       Loop at ITAB2.
         Read table ITAB1 with key Field1 = ITAB2-Field1.
         If sy-subrc <> 0.
         delete ITAB2.
         endif.
       Endloop.
    3. If any better way is found, i will let u know.
    Hope it helps.
    Regards,
    Amit M.

  • How to compare two internal table and store value in third table

    Dear All,
                  There is two tabel say I_T1 & T2, in I_T1 there are 4 rows , in T2 there are multiple rows against the same field. Say there is a filed X common in both table .
    Value of I_T1-X are
    10
    20
    50
    90
    and value ot T2-X are
    10
    15
    20
    30
    40
    50
    .100
    Now i want to fetch data form T2 against the common field of I_T1-X and store into other internal table.
    Plz suggest me the proper way of doing this.
    Rewards points assured for proper answer.
    Regards,
    Gulrez Alam

    hi this is like your requirement.
    in this i am storing the values into the final table
    REPORT  ZZZZ000000.
    tables:mara,marc,mard,makt.
    data:begin of it_mara occurs 0,
         matnr like mara-matnr,
         mtart like mara-mtart,
         meins like mara-meins,
         end of it_mara.
    data:begin of it_marc occurs 0,
         matnr like marc-matnr,
         pstat like marc-pstat,
         werks like marc-werks,
         end of it_marc.
    data:begin of it_mard occurs 0,
         werks like mard-werks,
         lgort like mard-lgort,
         labst like mard-labst,
         end of it_mard.
    data:begin of it_final occurs 0,
         matnr like mara-matnr,
         mtart like mara-mtart,
         meins like mara-meins,
         pstat like marc-pstat,
         werks like marc-werks,
         lgort like mard-lgort,
         labst like mard-labst,
         maktx like makt-maktx,
         end of it_final.
    select-options:s_matnr for mara-matnr.
    select  matnr
            mtart
            meins
            from mara
            into table it_mara
            where matnr in s_matnr.
            if not it_mara[] is initial.
            select matnr
                   pstat
                   werks
                   from marc
                   into table it_marc
                   for all entries in it_mara
                   where matnr = it_mara-matnr.
                   if not it_marc[] is initial.
                   select werks
                          lgort
                          labst
                          from mard
                          into table it_mard
                          for all entries in it_marc
                          where werks = it_marc-werks.
                   endif.
          endif.
    loop at it_mara.
    it_final-matnr = it_mara-matnr.
    it_final-mtart = it_mara-mtart.
    it_final-meins = it_mara-meins.
    read table it_marc with key matnr = it_mara-matnr.
    it_final-werks = it_marc-werks.
    it_final-pstat = it_marc-pstat.
    read table it_mard with key werks = it_marc-werks.
    it_final-lgort = it_mard-lgort.
    it_final-labst = it_mard-labst.
    if sy-subrc = 0.
    select maktx from makt into it_final-maktx where matnr = it_final-matnr.
    endselect.
    endif.
    append it_final.
    endloop.
    loop at it_final.
    write:/ it_final-matnr under 'material',
            it_final-mtart under 'material type',
            it_final-meins under 'unit of measure',
            it_final-werks under 'plant' ,
            it_final-pstat under 'status',
            it_final-lgort under 'storage loc',
            it_final-labst under 'stock',
            it_final-maktx.
    endloop.
    reward points if useful,
    venkat.

  • Comparing two internal tables

    HI all!
    I have two internal tables with single field values as below :
    1st Internal Table : A,B,C,D
    2nd Internal Table : A,B,C,D,E,F,G,
    Now I want to compare these two Int. tables and delete the second int. table with values which are not there in the first int. table.Any simple logic to get this.
    Regards
    Pavan

    Sort internal table 1 by A B C D.
    Now ..
    copy contents of 2nd table to a temp table.
    loop at 2nd internal table.
    read 1st internal table with key a = 2internal table a
                                     b = 2internal table b
    c = 2internal table c
    d = 2internal table d.
    if sy-subrc ne 0.
    delete entry from temp table.
    now refresh table 2.
    copy contents of temp to table 2.
    Guys,
         I guess DELETING THE SAME TABLE WITHIN A LOOP .. ENDLOOP is not advisable.Please correct me if i m wrong.
    endif.
    endloop.
    Message was edited by: Nishanth Bhandar
    Message was edited by: Nishanth Bhandar

  • Dynamic internal table ( make one internal table parts of the record )

    hello i am doing a program that look for document billing put it in a internal table then loop the internal table and use the FM SD_DOCUMENT_FLOW_GET for get the document flow that fm return a table and i need make every record of that table part of the currect register , i already do this in a ugly static way but i am looking a dynamic way of do this , i know that the ABAP OO is the way but i am no able to get this approarch ( i am noob in abap and any experience with OO programing )
    i will show the code for better understanding of it
    pd: is a crappy code i know sorry
    [CLick Here for the see the Code ( pastebin )|http://linuxlatino.pastebin.com/m39120e69]

    thanks all for the answer , but i will try explain better my problem :
    i have a it_data interntal table with document bill record i do a loop to that table and used the vbeln field in the FM for get the docment flow of that document billing number now the output of the FM is a table and i need take each record of that table am make it part of the current record of it_Data.
    Example:
    it_Data without the it_docflow data
    *Sales ORg*   *Distri.Channel*      *Billing Type*    *Payer*         *Sold-to-party*        vbeln*
    TP01         C1                     ZT17           1000524     1000524                 85003435 ..........
    it_docflow table ( FM Output ):
    *DOCNUM     ITEMNU    DOCNUV    ITEMNU            Description*
    53107842   000000                          000000         Standard Order
    65004606   000000       53107842   000000        Outbound Delivery
    75179356   000000      65004606   000000         Invoice
    57000118   000000      75179356   000000        Returns
    85003435   000000      57000118   000000        Credit for Returns
    5200003681 000000     85003435   000000       Accounting Doc.
    now the it_docflow data add in the it_data record:
    53107842  Standard Order  65004606 Outbound Delivery 75179356  Invoice  57000118 Returns  85003435 Credit for Returns 5200003681 Accounting Doc   TP01         C1                     ZT17           1000524     1000524                 85003435 .........
    i hope this explain better my problem here , thanks again

  • Populating two dynamic internal tables and displaying the O/p as ALV

    I want to develop a abap prototype program report for the SD document flow analysis...
    There is a Fm : RV_ORDER_FLOW_INFORMATION in which if we pass the Sales order number it returns the flows as VBFA_TAB.
    I need to populate two dynamic ITAB1 and ITAB2
    the structure of ITAB1 should be like ColNm1....ColNmn
    The values for ColNm1 will be Sales Order ColNm2 as Delivery or smthng else depending on  field vbtyp_n.
    ITAB 2 should have the corresponding values accly to ITAB1.
    Then we need to display in ALV o/p.
    The tables should be populated dynamically.
    Can anybody throw some light on it and plz do write back with sample code to do the logic of it.

    Search in SDN with Dynamic internal tables.
    you get lot of code samples and Discussions related to Dynamic internal tables.
    you can also check with this class CL_ALV_TABLE_CREATE

  • Compare two internal tables

    hi everybody
    i have two internal tables  ITAB1 AND ITAB2
    I WANT TO COMPARE THE CONTENTS OF THESE INTERNAL TABLES HOW TO DO THIS
    REGARDS
    HRIDHANJILI

    Hello Hridhayanjili
    The most detailed comparison is to use the same logic as change documents are prepared. Assuming both of your itabs are of structure struc_a. Then define the following type:
    TYPES: BEGIN OF ty_s_itab_di. 
    INCLUDE TYPE struc_a.
    TYPES: CHIND  TYPE bu_chind.
    TYPES: END OF ty_s_itab_di.
    TYPES: ty_t_itab_di  TYPE STANDARD TABLE OF ty_s_itab_di
                         WITH DEFAULT KEY.
    DATA: 
      gt_itab_old  TYPE ty_t_itab_di, 
      gt_itab_new  TYPE ty_t_itab_di.
    Fill itabs gt_Itab_old with the corresponding data of itab1 and gt_itab_new with the corresponding data of itab2.
    Very important: sort you itabs either by all key fields or by all fields.
    Call function CHANGEDOCUMENT_PREPARE_TABLES with the following parameters
    - CHECK_INDICATOR = ' '
    - TABLE_NEW = gt_Itab_new
    - TABLE_OLD = gt_itab_old
    The function module will remove identical lines from both itabs. New entries in gt_itab_New will have CHIND = 'I' and deleted entries in gt_itab_old will have CHIND = 'D'.
    Read the documentation of the function module and play around with it. You will see that this a quite easy yet powerful approach for comparing itabs.
    Regards
    Uwe

  • How to export internal table and pass the internal table to another screen?

    Hi,
    I have a sql SELECT statement that select data from table into internal table. I would like to export out the internal table and pass to another screen and display the data in ALV list. How to export it out? I try but the error given was " The type of "OUT_SELECT_ITAB" cannot be converted to the type of  "itab_result".
    Another question is, how to pass the internal table that i export out from the function module to another screen?
    Here is the code
    ==============================================================
    FUNCTION ZNEW_SELECT_ZSTUD00.
    ""Local Interface:
    *"  IMPORTING
    *"     REFERENCE(IN_SELECT_YEAR) TYPE  ZSTUD00-EYEAR
    *"  EXPORTING
    *"     REFERENCE(OUT_RESULT) TYPE  CHAR9
    *"     REFERENCE(OUT_SELECT_ITAB) TYPE  ZSTUD00
    *& Global Declarations
    DATA: itab TYPE ZSTUD00,
          itab_result TYPE TABLE OF ZSTUD00.
    *& Processing Blocks called by the Runtime Environment
    itab-eyear = IN_SELECT_YEAR.
    SELECT *
    FROM ZSTUD00
    INTO TABLE itab_result
    WHERE eyear = IN_SELECT_YEAR.
    IF sy-subrc = 0.
      out_result = 'Success'.
      OUT_SELECT_ITAB = itab_result.
    ELSE.
      out_result = 'Fail'.
    ENDIF.
    ENDFUNCTION.
    ===============================================================
    Please advise. Thanks
    Regards,
    Rayden

    Hi Nagaraj,
    I try to change it in Tables tab page but it state that TABLES parameters are obsolete. when i "Enter". I try to "Enter" again. it seem to be ok but it stil give me the same error.
    ================================================================
    FUNCTION ZNEW_SELECT_ZSTUD00.
    ""Local Interface:
    *"  IMPORTING
    *"     REFERENCE(IN_SELECT_YEAR) TYPE  ZSTUD00-EYEAR
    *"  EXPORTING
    *"     REFERENCE(OUT_RESULT) TYPE  CHAR9
    *"  TABLES
    *"      OUT_SELECT_ITAB STRUCTURE  ZSTUD00
    *& Global Declarations
    DATA: itab TYPE ZSTUD00,
          itab_result TYPE TABLE OF ZSTUD00.
    *& Processing Blocks called by the Runtime Environment
    itab-eyear = IN_SELECT_YEAR.
    SELECT *
    FROM ZSTUD00
    INTO TABLE itab_result
    WHERE eyear = IN_SELECT_YEAR.
    IF sy-subrc = 0.
      out_result = 'Success'.
      OUT_SELECT_ITAB = itab_result.
    ELSE.
      out_result = 'Fail'.
    ENDIF.
    ENDFUNCTION.
    ===============================================================
    regards,
    Rayden

  • Comparing two tables and picking the records

    I have two tables A and B.  I have to compare a column ID in both table A and table B  A.ID=B.ID  And based on the above comparison if the match is found I need to pick the records from table A and if no match then need to pick the records from table B  My problem is if I join then I will have table A and table B as one record and will be difficult to separate out.  Please let me know how this can be acheived.  Thnx.

    I have two tables A and B.  I have to compare a column ID in both table A and table B  A.ID=B.ID  And based on the above comparison if the match is found I need to pick the records from table A and if no match then need to pick the records from table B  My problem is if I join then I will have table A and table B as one record and will be difficult to separate out.  Please let me know how this can be acheived.  Thnx.

  • Loop at internal table and get the right line

    Hi,
    I've a table like this sorted by material1 and date.
    Material 1...Date..........Material 2...Stock 
    A1.............01/01/08........A2..........100
    A1.............01/01/07........A2..........150
    B1.............01/05/08........B1..........50
    B1.............01/03/07........B2..........100
    B1.............01/02/07........B3..........75
    I need to put in another table only the line for material1 which has the highest date.
    For this example, line 1 and 3 should be selected.
    Can anyone tell me how to code this??
    Thanks.

    Hi tarick,
    Try this,,
    Create another internal table  itab2 of type itab1 and copy all entries of itab1 to itab2.
    itab2[] = itab1[].
    Now delete adjacent duplicates from itab2 comparing material1.
    DELETE ADJACENT DUPLICATES FROM itab2 comparing material1.
    Effect
    Deletes adjacent duplicate entries from the internal table itab2. If there are n duplicate entries in succession, the first entry is retained, and the following n-1 entries are deleted.
    Reward Points if Helpful.
    Regards,
    Sachin M M

  • Problem while comparing two internal tables

    I have to modify work start date which are initial in the data base table for the records in the flat file.
    my code is:
    REPORT  ZAUFK_WORKSTARTDATE_UPDATE                 .
    Tables Declaration
    TABLES: AUFK.
    Type pools Declaration
    TYPE-POOLS : SLIS.
    Internal Table Declaration
    DATA: I_AUFK LIKE AUFK OCCURS 0 WITH HEADER LINE,
          IT_AUFK LIKE AUFK OCCURS 0 WITH HEADER LINE,
          ITAB1 LIKE ALSMEX_TABLINE OCCURS 0 WITH HEADER LINE.
    DATA: BEGIN OF I_AUFK1 OCCURS 0,
            AUFNR(12),
            AUART(4),
          END OF I_AUFK1.
    Data Declaration
    DATA I_FIELDCAT TYPE SLIS_FIELDCAT_ALV OCCURS 0.
    DATA WA_FCAT LIKE LINE OF I_FIELDCAT.
    DATA: B1 TYPE I VALUE 1,
          C1 TYPE I VALUE 1,
          B2 TYPE I VALUE 256,
          C2 TYPE I VALUE 65536.
    Selection Screen Declaration
    SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
      PARAMETERS: P_FILE LIKE RLGRAP-FILENAME.
      SELECT-OPTIONS: S_AUFNR FOR AUFK-AUFNR,
                      S_AUART FOR AUFK-AUART.
      PARAMETERS: P_USER7 LIKE AUFK-USER7 DEFAULT '20070101' OBLIGATORY.
    SELECTION-SCREEN END OF BLOCK B1.
    SELECTION-SCREEN BEGIN OF BLOCK B2 WITH FRAME TITLE TEXT-002.
    PARAMETERS: R1 RADIOBUTTON GROUP G1 DEFAULT 'X' USER-COMMAND UCOMM1, " Upload using File Path
                R2 RADIOBUTTON GROUP G1. " Uplaod using particular IO's
    SELECTION-SCREEN END OF BLOCK B2.
    To get F4 Help for File path on selection screen.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.
      CALL FUNCTION 'F4_FILENAME'
        EXPORTING
          PROGRAM_NAME  = SYST-CPROG
          DYNPRO_NUMBER = SYST-DYNNR
        IMPORTING
          FILE_NAME     = P_FILE.
    To disbale the filepath when r2 radiobutton is selected
    AT SELECTION-SCREEN OUTPUT.
    LOOP AT SCREEN.
    Check if R1 is checked
    IF R1 = 'X'.
        IF SCREEN-NAME = 'S_AUFNR-LOW' OR
          SCREEN-NAME = 'S_AUFNR-HIGH' OR
          SCREEN-NAME = 'S_AUART-LOW' OR
          SCREEN-NAME = 'S_AUART-HIGH'.
    Make the Internal order number and order type field disable from the selection screen
            SCREEN-INPUT = '0'.
            MODIFY SCREEN.
        ENDIF.
    ELSEIF R2 = 'X' AND SCREEN-NAME = 'P_FILE'.
    Make the file path field disappear from the selection screen
            SCREEN-INPUT = 0.
            MODIFY SCREEN.
        ENDIF.
    ENDLOOP.
    Start of executable code
    START-OF-SELECTION.
    To get the relavent IO data from the order master data table
    SELECT *
           FROM AUFK
           INTO TABLE I_AUFK
           WHERE AUFNR IN S_AUFNR
           AND AUART IN S_AUART
           AND ( AUART = '5200' OR AUART = '5500'
           OR AUART = '5700' OR AUART = '8500'
           OR AUART = '8700' ).
    Table must be updated using flat file
      IF R1 = 'X'.
    To Upload Excel sheet data into an internal table
        CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
          EXPORTING
            FILENAME                = P_FILE
            I_BEGIN_COL             = B1
            I_BEGIN_ROW             = C1
            I_END_COL               = B2
            I_END_ROW               = C2
          TABLES
            INTERN                  = ITAB1
          EXCEPTIONS
            INCONSISTENT_PARAMETERS = 1
            UPLOAD_OLE              = 2
            OTHERS                  = 3.
        IF SY-SUBRC <> 0.
          MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
          WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
        ENDIF.
    To organize the data in the internal table(excel data) as per our requirement
        PERFORM ORGANIZE_UPLOADED_DATA.
       <b> LOOP AT I_AUFK1.
    Comparing the excel data and the database table data
           READ TABLE I_AUFK WITH KEY AUFNR = I_AUFK1-AUFNR.
             IF SY-SUBRC EQ 0.
    Check if the the work start date is initial(blank)
                IF I_AUFK-USER7 IS INITIAL.
    If work start is initial move the value in p_user7 to the work start date field in i_aufk
                 MOVE P_USER7 TO I_AUFK-USER7.
                 MODIFY I_AUFK.
    Moving the data which is changed into it_aufk internal table(this table is for displaying the updated records)
                 MOVE-CORRESPONDING I_AUFK TO IT_AUFK.
                 APPEND IT_AUFK.
              ENDIF.
          ENDIF.
        ENDLOOP.
    endif.</b>
    WA_FCAT-FIELDNAME = 'AUFNR'.
      WA_FCAT-TABNAME = 'I_AUFK'.
      WA_FCAT-SELTEXT_M = 'Internal Order Number'.
      WA_FCAT-OUTPUTLEN = 12.
      APPEND WA_FCAT TO i_fieldcat.
      WA_FCAT-FIELDNAME = 'AUART'.
      WA_FCAT-TABNAME = 'I_AUFK'.
      WA_FCAT-SELTEXT_M = 'Order Type'.
      WA_FCAT-OUTPUTLEN = 4.
      APPEND WA_FCAT TO I_FIELDCAT.
      WA_FCAT-FIELDNAME = 'KTEXT'.
      WA_FCAT-TABNAME = 'I_AUFK'.
      WA_FCAT-SELTEXT_M = 'Description'.
      WA_FCAT-OUTPUTLEN = 40.
      APPEND WA_FCAT TO I_FIELDCAT.
      WA_FCAT-FIELDNAME = 'USER7'.
      WA_FCAT-TABNAME = 'I_AUFK'.
      WA_FCAT-SELTEXT_M = 'Work Start Date'.
      WA_FCAT-OUTPUTLEN = 10.
      APPEND WA_FCAT TO I_FIELDCAT.
    Updating the AUFK(Internal Order Data Table) using i_aufk
    *MODIFY AUFK FROM TABLE I_AUFK.
    Check if the database table is modified
    *IF SY-SUBRC = 0.
    Display the modified data
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
       I_CALLBACK_PROGRAM                = SY-REPID
       I_GRID_TITLE                      = 'List of updated Records'
       IT_FIELDCAT                       = I_FIELDCAT[]
      TABLES
        T_OUTTAB                          = IT_AUFK[]
    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.
    ENDIF.
    *&      Form  ORGANIZE_UPLOADED_DATA
          text
    FORM ORGANIZE_UPLOADED_DATA .
      SORT ITAB1 BY ROW COL.
      LOOP AT ITAB1.
        CASE ITAB1-COL.
          WHEN 1.
            I_AUFK1-AUFNR = ITAB1-VALUE.
          WHEN 2.
            I_AUFK1-AUART = ITAB1-VALUE.
        ENDCASE.
        AT END OF ROW.
          APPEND I_AUFK1.
        ENDAT.
      ENDLOOP.
      LOOP AT I_AUFK1.
      CONCATENATE '000000' I_AUFK1-AUFNR INTO I_AUFK1-AUFNR.
      MODIFY I_AUFK1.
      ENDLOOP.
    ENDFORM. " ORGANIZE_UPLOADED_DATA
    The bold are is were i'm facing problem. Please help me .its urgent.

    Hi try using the below code... 
    LOOP AT I_AUFK1.
    Comparing the excel data and the database table data
    READ TABLE I_AUFK WITH KEY AUFNR = I_AUFK1-AUFNR.
    IF SY-SUBRC EQ 0.
    Check if the the work start date is initial(blank)
    IF I_AUFK-USER7 IS INITIAL.
    If work start is initial move the value in p_user7 to the work start date field in i_aufk
    MOVE P_USER7 TO I_AUFK-USER7.
    [<u>b]MODIFY I_AUFK from i_aufk transporting user7.</b></u>
    Moving the data which is changed into it_aufk internal table(this table is for displaying the updated records)
    MOVE-CORRESPONDING I_AUFK TO IT_AUFK.
    APPEND IT_AUFK.
    ENDIF.
    ENDIF.
    ENDLOOP.
    endif.
    if you can't still solve some more questions
    what is teh sy-subrc of teh read ..
    what does the header line contain after teh read
    and what happens after modify.. does the contents change?

  • How to compare two excel reports and find the difference in BI Publisher

    Hi All,
    I have a requirement that needs to compare two excel reports in XML Publisher 5.6.2. or BI publisher 10.1.3.4
    If anybody has an idea about this pls help us.
    Thanks,

    Since our customer wants to have this comparison only with BI reports....here is the scenario how the comparison should be..
    Now,we have a parameters called Customer name and version id. Version id list will be refreshed based on the customer selection.
    User can generate the report based on the selected customer name and version id. These data are fetch from the oracle database and we are using Data Template in the BI Publisher.
    Now the requirement is customer wants to compare two version id data. for example, v1.2 and v1.3
    Now they wanna to see both the reports while generating in the same work sheet, like, v1.2report should display in the left side and the v1.3report has to display in the right hand side of the same work sheet.
    Now...If there is any addition happened in v1.3 report,then that cell/data should display as a green color in that report.
    If any deletion happened in v1.3report then that should be in the red color.
    If any modification happened in v1.3 then that should be in the yellow color.
    If there is no difference then that should display as it is.
    the thing is that, the both the reports (v1.2 and v1.3)should display side by side in the same worksheet with the format and everything........only the difference should be highlighted.
    Template is same for both the reports..
    To display the data for both versions i think i can generate the template side by side of both in the same worksheet.
    Now, My question is how to find the difference of data in the RTF Template for both the versions
    Can anybody assist me?
    Thanks,
    Edited by: user753355 on Jun 9, 2009 12:03 AM
    Edited by: user753355 on Jun 9, 2009 12:06 AM
    Edited by: user753355 on Jun 9, 2009 12:16 AM
    Edited by: user753355 on Jun 10, 2009 3:59 AM

  • Installed java and deleted the files---NOT ABLE TO INSTALL java AGAIN

    1) I installed jre,jdk1.6 and then without uninstalling i deleted the files.
    2) I now want to install java for creating web application.
    But I am not able to install. While installing I get a "file corrupted" message and the installation aborts.
    What can I do to install java again?

    With the info provided the best advice I can give is reformat your drive and start fresh.
    If that doesn't sound palatable, then you could maybe tell us at least what OS you are running and if you really want help the exact version of the OS.
    Then you can tell us what you have already tried. Like running the uninstaller now, installing to a defernt directory, etc.
    Also have you tried redownloading the JDK? Maybe the file really is corrupted.
    And while file is it saying is corrupted.
    Like everything else here, you need help, we don't need to help you, and we can't read minds. So if you are willing to put forth a tiny bit more effort to provide as much info as possible, you are more likely to get a meaningful response with a solution.
    JSG

  • Refresh table and display the records after insertion of data from back end

    Hi Experts,
    JDEV 11.1.2.1
    I have a useacase which needs data to be inserted from oracle back end procedure and displayed in a ADF Table Component, when a button is pressed.
    is this possible?..if yes , how?
    Is view object will automatically refreshed and fetches newly created(from back end) rows?
    thankz in advance
    PMS

    Hi user707,
    thankz for ur reply....
    i think after executing a procedure you want to call commit operation. better you can perform this.getDbtransaction().commit In Application Module;yes i want to commit transaction after executing back end procedure using preparedStatement.Procedure is for inserting data into same table , which used for creating VO and Read only ADF Table.Procedure is executed fine, but newly created records are not getting into ADF table.Once i did commit opeartion inside back end procedure, whole records are getting into ADF Table.
    Is there any way to get whole records without doing Commit operation inside Back end procedure?
    PMS

  • Joining Two Internal Tables - ( Urgent )

    Could anybody please give me the whole code for joining two internal tables
    and putting the data in a third internal table. Please, very urgent.
                                                                                    Regards,
                                                                                    SAURAV

    Hi,
      Refer this code
    *&      Form  SUB_READ_VBRK
          text
    FORM sub_read_vbrk.
      SELECT vbeln
             rplnr
             bukrs
             FROM vbrk
             INTO TABLE it_vbrk
             WHERE vbeln IN s_vbeln
             AND   rplnr NE ' '.
      IF sy-subrc EQ 0.
        SORT it_vbrk BY rplnr.
      ENDIF.
    ENDFORM.                    " SUB_READ_VBRK
    *&      Form  SUB_READ_FPLTC
          text
    FORM sub_read_fpltc.
      IF NOT it_vbrk[] IS INITIAL.
        SELECT fplnr
               fpltr
               ccnum
               FROM fpltc
               INTO TABLE it_fpltc
               FOR ALL ENTRIES IN it_vbrk
               WHERE fplnr EQ it_vbrk-rplnr
               AND   ccins EQ 'GIFC'.
        IF sy-subrc EQ 0.
          SORT it_fpltc BY fplnr.
        ENDIF.
      ENDIF.
    ENDFORM.                    " SUB_READ_FPLTC
    *&      Form  SUB_COLLECT_DATA
          text
    FORM sub_collect_data.
    *--Local variables
      DATA : lv_count(3) TYPE c.
      IF NOT it_fpltc[] IS INITIAL.
        LOOP AT it_fpltc INTO wa_fpltc.
          lv_count = wa_fpltc-fpltr+3(3).
          wa_final-ccnum = wa_fpltc-ccnum.
          wa_final-rfzei = lv_count.
          CLEAR : wa_vbrk.
          READ TABLE it_vbrk INTO wa_vbrk WITH KEY rplnr = wa_fpltc-fplnr
                                                   BINARY SEARCH.
          IF sy-subrc EQ 0.
            wa_final-vbeln = wa_vbrk-vbeln.
            wa_final-bukrs = wa_vbrk-bukrs.
          ENDIF.
          APPEND wa_final TO it_final.
          CLEAR : wa_vbrk,
                  wa_fpltc,
                  lv_count.
        ENDLOOP.
      ENDIF.
    ENDFORM.                    " SUB_COLLECT_DATA
    Regards,
    prashant

Maybe you are looking for

  • IMac (24-inch Mid 2007), Mac OS X (10.6.8) small water spill on keyboard. Why can't I access web now?

    I accidentally spilled water on keyboard for my iMac (24-inch Mid 2007), Mac OS X (10.6.8). Since then, I have dryed it out. Several keys aren't working so I tried another, albeit older, keyboard. That one worked fine but for some reason I cannot acc

  • Using /1BCDWB/DOCPARAMS - LANGU in Interface coding initialization

    Hello, I have build an pdf interactive offline form using a DDIC form interface. I am using this interface (FM) in my print report like call function module fm_name exporting   /1BCDWB/DOCPARAMS One important parameter of /1BCDWB/DOCPARAMS that is fi

  • Java ENV variable on Linux

    Hi , I am new to linux can any one please guide me the steps to follow to update the ENV variable for JAVA_HOME in Linux. Thanks Raghav

  • Uninstall Adobe Reader 8.1.2 or 9.1

    I'm trying to uninstall adobe reader 8.1.2 and 9.1 and I received the following warning: Warning 1314. The specified path %APPDATA%\Adobe\Acrobat|8.0\Updater\is unavailable. I have follow different instructions to uninstall with not results. Can some

  • Monitor goes black for a few seconds then recovers

    This has been a great machine. Since 2014, the Monitor keeps going blank for 3/4 seconds then comes back. I have done my driver search and have installed the updated driver software but the problem persists. Please help. Bijou