How to read an internal table by comparing the values of key fields
hi ,
i want to read internal table with multiple values for the key field . can anyone suggest the syntax or method for doing this,
thanks in advance.
regards,
manoj
Hi,
Read statement will read only one value at a time..
You can only compare with different values.
example :
read table it_mara into wa_mara with key matnr = '1000'
matnr = '2000'
matnr = '3000'.
if all the 3 records are found in the internal table then it will read the 1 record.
Regards
Satish Boguda
Similar Messages
-
Read Internal Table based on Multiple Values for Key Field
Hi Gurus,
i have one query can you tell me how read an internal table it_kna1 for multiple values of land1 DE US IND etc.
i had tried as below but i could not can you try and let me knwo at the earliest.
here i want read the values with DE or US and want further prosess them.
REPORT YC001.
tables kna1.
select-options: cust for kna1-kunnr.
data: begin of it_kna1 occurs 0,
kunnr like kna1-kunnr,
name1 like kna1-name1,
land1 like kna1-land1,
end of it_kna1.
select kunnr name1 land1 into table it_kna1 from kna1 where kunnr in cust.
read table it_kna1 with key land1 = ( 'DE' OR 'US' ) .
can anybody suggest me some solution.
Thanks,
Jeevi.This should be what you need:
REPORT ztest NO STANDARD PAGE HEADING LINE-SIZE 80 MESSAGE-ID 00.
TABLES kna1.
SELECT-OPTIONS: cust FOR kna1-kunnr.
DATA: BEGIN OF it_kna1 OCCURS 0,
kunnr LIKE kna1-kunnr,
name1 LIKE kna1-name1,
land1 LIKE kna1-land1,
END OF it_kna1.
DATA: itab_index LIKE sy-tabix.
SELECT kunnr name1 land1
INTO TABLE it_kna1
FROM kna1
WHERE kunnr IN cust.
SORT it_kna1 BY land1.
READ TABLE it_kna1 WITH KEY
land1 = 'DE'
BINARY SEARCH.
itab_index = sy-tabix.
WHILE sy-subrc = 0.
itab_index = itab_index + 1.
WRITE: /001 it_kna1-kunnr, it_kna1-land1, it_kna1-name1.
READ TABLE it_kna1 INDEX itab_index.
IF it_kna1-land1 <> 'DE'.
sy-subrc = 99.
ENDIF.
ENDWHILE.
SKIP 1.
READ TABLE it_kna1 WITH KEY
land1 = 'US'
BINARY SEARCH.
itab_index = sy-tabix.
WHILE sy-subrc = 0.
itab_index = itab_index + 1.
WRITE: /001 it_kna1-kunnr, it_kna1-land1, it_kna1-name1.
READ TABLE it_kna1 INDEX itab_index.
IF it_kna1-land1 <> 'US'.
sy-subrc = 99.
ENDIF.
ENDWHILE.
Rob -
How to read an internal table with more than one (2 or 3) key field(s).
how to read an internal table with more than one (2 or 3) key field(s). in ecc 6.0 version
hi ,
check this..
report.
tables: marc,mard.
data: begin of itab occurs 0,
matnr like marc-matnr,
werks like marc-werks,
pstat like marc-pstat,
end of itab.
data: begin of itab1 occurs 0,
matnr like mard-matnr,
werks like mard-werks,
lgort like mard-lgort,
end of itab1.
parameters:p_matnr like marc-matnr.
select matnr
werks
pstat
from marc
into table itab
where matnr = p_matnr.
sort itab by matnr werks.
select matnr
werks
lgort
from mard
into table itab1
for all entries in itab
where matnr = itab-matnr
and werks = itab-werks.
sort itab1 by matnr werks.
loop at itab.
read table itab1 with key matnr = itab-matnr
werks = itab-werks.
endloop.
regards,
venkat. -
How to populate dynamic internal table according to the field names
Hi ,
Iam having a dynamic internal table <DYN_TABLE> , it has fields like
MATNR MAKTX MEINS BISMT MTART ...
Now my requirement is i need to fill them according to the fieldname from another internal table (static) .
The order of internal table (static) and dynamic internal are not same.
kindly help me.Hi,
Here is the code. Please reward points if helpful.
REPORT z_dynamic.
TYPE-POOLS : abap.
FIELD-SYMBOLS: <dyn_table> TYPE STANDARD TABLE,
<dyn_wa>,
<dyn_field>.
DATA: dy_table TYPE REF TO data,
dy_line TYPE REF TO data,
xfc TYPE lvc_s_fcat,
ifc TYPE lvc_t_fcat.
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME.
PARAMETERS: p_table(30) TYPE c DEFAULT 'T001'.
SELECTION-SCREEN END OF BLOCK b1.
START-OF-SELECTION.
PERFORM get_structure.
PERFORM create_dynamic_itab.
PERFORM get_data.
PERFORM write_out.
*& Form get_structure
text
FORM get_structure.
DATA : idetails TYPE abap_compdescr_tab,
xdetails TYPE abap_compdescr.
DATA : ref_table_des TYPE REF TO cl_abap_structdescr.
Get the structure of the table.
ref_table_des ?=
cl_abap_typedescr=>describe_by_name( p_table ).
idetails[] = ref_table_des->components[].
LOOP AT idetails INTO xdetails.
CLEAR xfc.
xfc-fieldname = xdetails-name .
xfc-datatype = xdetails-type_kind.
xfc-inttype = xdetails-type_kind.
xfc-intlen = xdetails-length.
xfc-decimals = xdetails-decimals.
APPEND xfc TO ifc.
ENDLOOP.
ENDFORM. "get_structure
*& Form create_dynamic_itab
text
FORM create_dynamic_itab.
Create dynamic internal table and assign to FS
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = ifc
IMPORTING
ep_table = dy_table.
ASSIGN dy_table->* TO <dyn_table>.
Create dynamic work area and assign to FS
CREATE DATA dy_line LIKE LINE OF <dyn_table>.
ASSIGN dy_line->* TO <dyn_wa>.
ENDFORM. "create_dynamic_itab
*& Form get_data
text
FORM get_data.
Select Data from table.
SELECT * INTO TABLE <dyn_table>
FROM (p_table).
ENDFORM. "get_data
*& Form write_out
text
FORM write_out.
Write out data from table.
LOOP AT <dyn_table> INTO <dyn_wa>.
DO.
ASSIGN COMPONENT sy-index
OF STRUCTURE <dyn_wa> TO <dyn_field>.
IF sy-subrc <> 0.
EXIT.
ENDIF.
IF sy-index = 1.
WRITE:/ <dyn_field>.
ELSE.
WRITE: <dyn_field>.
ENDIF.
ENDDO.
ENDLOOP.
ENDFORM. "write_out -
Create a new column in a table that compares the value of one column with its previous value
The DDL:
DECLARE
@T TABLE
IDNO
int,
name
varchar(40),
[Date]
datetime2,
Price1
float,
Price2
float
DECLARE
@K TABLE
IDNO
int,
name
varchar(40),
[Date]
datetime2,
Price1
float,
Price2
float
INSERT
INTO @T
VALUES(22,'C_V_Harris','2014-01-02 10:23:49.0000000',
23.335,
23.347)
INSERT
INTO @T
VALUES(21,'C_V_Harris','2014-01-02 10:05:13.0000000',
23.357,
23.369)
INSERT
INTO @T
VALUES(20,'C_V_Harris','2014-01-02 09:56:15.0000000',
23.364,
23.377)
INSERT
INTO @T
VALUES(19,'C_V_Harris','2014-01-02 09:45:26.0000000',
23.351,
23.367)
INSERT
INTO @T
VALUES(18,'C_V_Harris','2014-01-02 09:43:20.0000000',
23.380,
23.396)
INSERT
INTO @T
VALUES(17,'C_V_Harris','2014-01-02 09:34:28.0000000',
23.455,
23.468)
INSERT
INTO @T
VALUES(16,'C_V_Harris','2014-01-02 09:30:37.0000000',
23.474,
23.486)
INSERT
INTO @T
VALUES(15,'C_V_Harris','2014-01-02 09:18:12.0000000',
23.419,
23.431)
INSERT
INTO @T
VALUES(14,'C_V_Harris','2014-01-02 09:16:06.0000000',
23.360,
23.374)
INSERT
INTO @K
SELECT
ROW_NUMBER()
OVER (ORDER
by IDNO)
AS RN,*
FROM
@T
SELECT
* FROM
@K
--not working:
SELECT
a.RN,a.Price2
FROM
@K a
INNER
JOIN @K
b
ON
a.RN=b.RN-1
WHERE
a.Price2>b.Price2
I need to create a view with a column (say 'Comp' below) that compares the value of each row in Price2 with the previous Price2 row, and it is greater then +1, the
same 0, and less -1.
The processed table should be:
IDNO
name
Date
Price1
Price2
Comp
22
C_V_Harris
1/2/2014 10:23:49
23.335
23.347
0
21
C_V_Harris
1/2/2014 10:05:13
23.357
23.369
1
20
C_V_Harris
1/2/2014 9:56:15
23.364
23.377
1
19
C_V_Harris
1/2/2014 9:45:26
23.351
23.367
-1
18
C_V_Harris
1/2/2014 9:43:20
23.38
23.396
1
17
C_V_Harris
1/2/2014 9:34:28
23.455
23.468
1
16
C_V_Harris
1/2/2014 9:30:37
23.474
23.486
1
15
C_V_Harris
1/2/2014 9:18:12
23.419
23.431
-1
14
C_V_Harris
1/2/2014 9:16:06
23.36
23.374
-1
How can I structure the statement to get (the most recent - order by date ) result for Comp?Satheesh Variath, I just had to make some corrections from your script to get the correct answer:
CREATE
VIEW vw_Comp
AS
SELECT
TOP 1 t.IDNO,t.name,t.[Date],t.Price1,t.Price2,
CASE
WHEN t.Price2
> LAG(Price2,1)
OVER (PARTITION
BY name
ORDER BY IDNO)
THEN 1
WHEN t.Price2
< LAG(Price2,1)
OVER (PARTITION
BY name
ORDER BY IDNo)
THEN -1
ELSE 0
END
AS Comp
FROM
@T t
ORDER
BY DATE
DESC
The adjustments: the selection of the most recent comparison (Top 1) and the use of the function LAG (instead of LEAD) to get the previous value of the column. -
Hi All,
powershell script Method required to read a value from registry and then taking the backup of that values in some text file.
For example the hive is
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\Path
and under path i need to take back up of values in some text file and then put some value in the registry after back is taken in text file.
Also how to read the text file values so that we can again write to registry hive back from the back up text file.
Your help is much appreciated.
Umeed4uI think you need to read this first:
http://social.technet.microsoft.com/Forums/scriptcenter/en-US/a0def745-4831-4de0-a040-63b63e7be7ae/posting-guidelines?forum=ITCG
Don't retire TechNet! -
(Don't give up yet - 12,830+ strong and growing) -
How to fetch data from an internal table by comparing the a value in loop
i have an internale table with two fields like parvw and vtext.
acc to valuue in parvw in loop we sholud fetch the corresponding value of vtext.
we should not use loop in loop .
ex code
select parvw vtext from tpart into table i_vtext where spras = sy-langu.
LOOP AT I_OUTPUT.
CASE I_OUTPUT-tabname.
WHEN 'VBPA'.
IF I_OUTPUT-fname = 'KUNNR' OR
I_OUTPUT-fname IS INITIAL.
MOVE I_OUTPUT-tabkey TO vbpa.
READ TABLE i_vtext WITH table KEY parvw = vbpa-*parvw .
IF sy-subrc = 0.
REPLACE '&' WITH i_vtext-vtext INTO I_OUTPUT-indtext.
ENDIF.
ENDIF.
WHEN 'VBAP'.
IF I_OUTPUT-fname IS INITIAL.
REPLACE '&' WITH 'item' INTO I_OUTPUT-indtext.
ENDIF.
ENDCASE.
IF I_OUTPUT-indtext(1) EQ '&'.
REPLACE '&' WITH I_OUTPUT-ftext(40) INTO I_OUTPUT-indtext.
ENDIF.Loop the main ITAB
and then use READ TABLE to fetch a row from the 2nd ITAB.
sort the main itab abd use binary search option in READ to improve the performance
Narendra -
Reading data from table and print the value based condition
hi
my table like this
slno | value1 | value2 |
1 0 5
2 5 10
3 10 15
assume n= 8 ( where n is user define)
i want output like
number 8 between value 5 and 10
plz helpHi,
Try:
Select 'Number '+ U_Value3 + ' Between '+ U_Value1'and 'U_Value2
From [dbo\].[@UDT T0\]
Where T0.U_Value3=[%0\] and T0.U_Value3 BETWEEN U_Value1 AND U_Value2
Thanks,
Gordon -
Filtering internal table using select-option values
Hi,
I got an internal table with select-option values. for eg. it_perno with the values I BT 000160 000170.
Now i got another second internal table which is have the person number. Now i need to filter this second internal table based on the values from the select option table. my question is
i can collect all the values from 160 to 170 in a separate table by looping over the select option table. and then based on the values filter the second internal table person number.
But what would be the case if the select option contains both intervals and multiple options. For eg.
I BT 000160 000170.
I EQ 000185.
So can you suggest any good solution, that based on this select option table i need to filter the second internal table Person number.
Thanks in advance.
Regards,
anbu.Hi,
Can you not use the select-options in the Select query while populating the internal table.
SELECT pernr FROM pa0000 INTO it_tab WHERE pernr IN s_pernr.
If you cannot do this and you do not want to delete the unwanted entries, then you can use the WHERE clause in the LOOP statement to process the specific entries required:
LOOP AT it_tab INTO wa_tab WHERE pernr IN s_pernr.
Regards,
Aparna Alashe. -
How to transfer from internal table to table control ?
How to transfer data from internal table to table control wihtout using select statement?
HI
GOOD
The commands in the flow logic are:
LOOP AT itab [INTO wa] WITH CONTROL ctrl.
ENDLOOP.
This statement assigns an internal table itab of the ABAP program to the table control and triggers a parallel loop run over the table control rows displayed on the screen and over the internal table itab. The additions INTO and WITH CONTROL are possible at the time of PBO, but not at PAI. The assignment of the loop to the table control takes place at PAI through the internal table.
Using the INTO addition, the fields of the internal table itab are written to the work area wa at the time of PBO and the content of wa is transported, line by line, to the identically-named fields of the table control on the screen. Without the INTO addition, you must use an internal table with a header line. Then the content of the header line is transported line by line to the identically-named fields of the table control on the screen at the time of PBO. No module is required for filling the table control rows.
Conversely, at the time of PAI, the internal table rows are not automatically filled with the contents of the table control rows. Instead, you must call a dialog module within the loop that modifies the table.
http://help.sap.com/saphelp_nw2004s/helpdata/en/9f/dbac5135c111d1829f0000e829fbfe/content.htm
http://help.sap.com/saphelp_nw2004s/helpdata/en/fa/0970a4543b11d1898e0000e8322d00/content.htm
THANKS
MRUTYUN^ -
How to define an internal table which have to be dynamic
Hallo,
here's a problem that i have to solve (but how ?).
I defined an internal Table with 2 columns:
col1: tablename
col2: fieldname
This table is filled with an unknown number of datasets like this:
dataset1: A001 KAPPL
dataset2: A001 KNUMH
dataset3: A903 KUNNR and so on.
I don't know which tablenames and fieldnames are contained.
Now i have to read those fields (e.g. KAPPL) from those tables (e.g. A001) into an internal table.
But i don't know how to define this internal table.
Could anyone help me please ?
Thanks a lot.
SilvioHi Wirth
DATA:
w_tabname TYPE w_tabname,
w_dref TYPE REF TO data,
table_name TYPE tadir-obj_name.
FIELD-SYMBOLS: <t_itab> TYPE ANY TABLE.
READ YOUR INTERNAL TABLE (DATA SET) AND GET THE TABLE NAME,
AND PASS IT TO W_TABNAME.
w_tabname = A001.
CREATE DATA w_dref TYPE TABLE OF (w_tabname).
ASSIGN w_dref->* TO <t_itab>.
Now use <t_itab> as your internal table to fetch data .
<t_itab> will have the structure of A001.
SELECT *
FROM (w_tabname) UP TO 10 ROWS
INTO TABLE <t_itab>.
Regards
Hareesh Menon -
How would you order an internal table e.g. itab according a specific field
Hello
How would you order an internal table e.g. itab according a specific field?
Would you be so kind and let me see an mini example
Thank you in advanceHi Tina,
You can sort the table as already mentioned, or if you want it always kept in a key sequence you could define it as a sorted table something like this:
types:
begin of itabline,
field1 type c,
field2 type n,
field3 ....
end of itabline.
DATA itab TYPE sorted table of itabline WITH UNIQUE key field1.
You can then insert and read entries by the key fields.
Hope that helps as an option!
Robin -
How to pass an internal table to LVC_FIELDCATALOG_MERGE
Hi Abap'ers
I want to know how to pass an internal table to the function module LVC_FIELDCATALOG_MERGE, as like we do in the FM REUSE_ALV_FIELDCATALOG_MERGE.
For Eg
v_name = 'I_OUTPUT'.
call function 'REUSE_ALV_FIELDCATALOG_MERGE'
exporting
i_program_name = wrk_repid
i_internal_tabname = v_name
i_inclname = wrk_repid
changing
ct_fieldcat = wrk_fld_cat
exceptions
inconsistent_interface = 1
program_error = 2
others = 3.
Where I_OUTPUT is the internal table name.Re: LVC_FIELDCATALOG_MERGE with internal table
Check this
In PBO,
Building the field catalog
PERFORM f9001_build_field_cat TABLES i_fieldcat
USING 'ZCSA_MARKETIING_EXPENSE_OUTPUT'
FORM f9001_build_field_cat TABLES p_fieldcat STRUCTURE lvc_s_fcat
USING value(p_structure).
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
i_structure_name = p_structure
CHANGING
ct_fieldcat = p_fieldcat[]
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE i013 WITH text-e05."Error in ALV field catalogue creation
LEAVE LIST-PROCESSING.
ENDIF.
ENDFORM. " f9001_build_field_cat
U can create a structure or example pass MARA then it will take the structure of MARA. -
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,
MohanHI 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 -
How meny types of internal tables?
how meny types of internal tables? can any one explain brifly what r their use?
INTERNAL TABLES:
Internal tables are holds the data which is having the same structure and storing it in working memory in ABAP. The data is stored line by line in the memory. The main purpose of internal table is for storing and formatting data from a database table within a program. It is used to minimize the DB access time in report programs.
Internal table are dynamic data objects, since they can contain any number of lines of a particular type. The maximum memory that can be occupied by an internal table (including its internal administration) is 2 gigabytes.
Types of Internal Tables :
1. Standard Internal Tables :
Standard tables have an internal linear index. The system can access records either by using the table index or the key. The response time for key access is proportional to the number of entries in the table. This means that standard tables can always be filled very quickly, since the system does not have to check whether there are already existing entries. WE can fill a standard table by appending lines (ABAP APPEND statement), and read, modify and delete entries by specifying the index (INDEX option with the relevant ABAP command).
2. Sorted tables :
Sorted tables are always saved sorted by the key. They also have an internal index. The system can access records either by using the table index or the key. The response time for key access is logarithmically proportional to the number of table entries, since the system uses a binary search. Entries are inserted according to the sort sequence defined through the table key.
3. Hashed tables :
Hashed tables have no linear index. You can only access a hashed table using its key. The response time is independent of the number of table entries, and is constant, since the system access the table entries using a hash algorithm. we cannot access a hashed table using its index.
Maybe you are looking for
-
Error while extending controller: class name is wrong or not included
Hi All, I am getting this error while I port my extended controller class to the custom top and assign this controller to the page. I have made sure its the class file that is copied. The directory is correct, the permissions were given using chmod 7
-
ITunes 7.1 Burning Problem
When I create a new playlist and burn that playlist to a blank cd in iTunes 7.1 it'll burn the tracks but it never seems to finalize the disk and iTunes locks up. Is this a common problem? What can I do to fix it?
-
How to find the user exit in BOM?
hi this is ganesh, my requirement is to put the check in bom header level at adminstrative data tab creation on field. so can you expain me the how to exit to header level in BOM.
-
Validator error - Extra data was encountered.
Hi All, I am working on Outbound EDI870, getting below Error: 2010.06.03 at 04:33:34:988: oracle.integration.platform.blocks.executor.WorkManagerExecutor$1@8f1195: B2B - (ERROR) Error -: B2B-51505: General validation error. at oracle.tip.b2b.doc
-
How do I start Java? I'm a novice.
I got a java book and just downloaded JDK 5.0 Update 3. After installing it, I couldn't find a way to start the program. There's no icons or exe. files that can do that. I was just going to try to type in some simple samples from the book. Now I can'