10-24-2006 10:02 PM
Hello friends,
I have 3 internal tables itab1, itab2, itab3.
I have a perform statement and each time i access the perform it has to do work with different internal table.
I can write 3 perform statements but I am thinking will it work only with one perform statement and changing the internal table.
Shejal.
10-24-2006 10:39 PM
Hi,
I got you what you are asking..If there is no internal table name like IT_MCHB use the internal table IT1_MCHB..Since all the three internal table are of the same structure..
FORM f1100_get_characteristics
CHANGING lt_mchd LIKE <b>it1_mchb</b>.
Thanks,
Naren
10-24-2006 10:05 PM
Hi,
Use tables statement..
TABLES: KNA1.
DATA: T_KNA1 LIKE KNA1 OCCURS 0 WITH HEADER LINE.
DATA: T_KNVV LIKE KNVV OCCURS 0 WITH HEADER LINE.
DATA: T_KNVP LIKE KNVP OCCURS 0 WITH HEADER LINE.
PERFORM FORM1 TABLES T_KNA1.
PERFORM FORM1 TABLES T_KNVV.
PERFORM FORM1 TABLES T_KNVP.
FORM FORM1 TABLES LT_INPUT.
ENDFORM.
Thanks,
Naren
10-24-2006 10:12 PM
Thanks Naren,
I kind of understood but am still confused.
I am pasting the part of the code,
SELECT matnr werks lgort charg cspem
FROM mchb
INTO TABLE it1_mchb
FOR ALL ENTRIES IN it1_zzmm0011
WHERE werks = it1_zzmm0011-werks
AND cspem <> 0.
SELECT matnr werks lgort charg cspem
FROM mchb
INTO TABLE it2_mchb
FOR ALL ENTRIES IN it2_zzmm0011
WHERE werks = it2_zzmm0011-werks
AND cspem <> 0.
SELECT matnr werks lgort charg cspem
FROM mchb
INTO TABLE it3_mchb
FOR ALL ENTRIES IN it3_zzmm0011
WHERE werks = it3_zzmm0011-werks
AND cspem <> 0.
PERFORM f1100_get_characteristics.
FORM f1100_get_characteristics.
LOOP AT it_mchb.
CLEAR: t_charac, za_objek, zi_objek, z_cuobj.
REFRESH: t_charac.
zi_objek+0(18) = it_mchb-matnr. " Material
zi_objek+18(10) = it_mchb-charg. " Batch Number
SELECT cuobj INTO z_cuobj FROM inob
UP TO 1 ROWS
WHERE klart = c_023 " 023 = Class Type for batches
AND obtab = c_mch1 " MCH1 = Object Table for batches
AND objek = zi_objek. " INOB object
ENDSELECT.
za_objek+0(18) = z_cuobj. " Reformat due to type conflicts
SELECT atinn atwrt atflv FROM ausp
INTO TABLE t_charac
WHERE objek = za_objek
AND atinn IN (z_lobm_mbdat,
z_zrfc_freeze_complete_time_hr).
SORT t_charac BY atinn atwrt.
Save this batch's availability date
CLEAR: t_charac.
READ TABLE t_charac WITH KEY atinn = z_lobm_mbdat
BINARY SEARCH.
IF sy-subrc = 0.
it_mchb-avail_date = t_charac-atflv.
ENDIF.
Save this batch's freeze time
CLEAR: t_charac.
READ TABLE t_charac
WITH KEY atinn = z_zrfc_freeze_complete_time_hr
BINARY SEARCH.
IF sy-subrc = 0.
it_mchb-freeze_time = t_charac-atflv.
ENDIF.
MODIFY it_mchb.
ENDLOOP.
ENDFORM. "f1100_get_characteristics
In the form end form i am usng it_mchb, but i want to modify it1_mchb, it2_mchb, it3_mchb.
I hope this helps.
Shejal.
10-24-2006 10:22 PM
Hi,
See the changes are in bold..
SELECT matnr werks lgort charg cspem
FROM mchb
INTO TABLE it1_mchb
FOR ALL ENTRIES IN it1_zzmm0011
WHERE werks = it1_zzmm0011-werks
AND cspem <> 0.
SELECT matnr werks lgort charg cspem
FROM mchb
INTO TABLE it2_mchb
FOR ALL ENTRIES IN it2_zzmm0011
WHERE werks = it2_zzmm0011-werks
AND cspem <> 0.
SELECT matnr werks lgort charg cspem
FROM mchb
INTO TABLE it3_mchb
FOR ALL ENTRIES IN it3_zzmm0011
WHERE werks = it3_zzmm0011-werks
AND cspem <> 0.
<b>PERFORM f1100_get_characteristics CHANGING it1_mchb.
PERFORM f1100_get_characteristics CHANGING it2_mchb.
PERFORM f1100_get_characteristics CHANGING it3_mchb.</b>
FORM f1100_get_characteristics
<b> CHANGING lt_mchd LIKE it_mchb</b> .
LOOP AT <b>lt_mchb</b>.
CLEAR: t_charac, za_objek, zi_objek, z_cuobj.
REFRESH: t_charac.
zi_objek+0(18) = <b>lt_mchb</b>-matnr. " Material
zi_objek+18(10) = <b>lt_mchb</b>-charg. " Batch Number
SELECT cuobj INTO z_cuobj FROM inob
UP TO 1 ROWS
WHERE klart = c_023 " 023 = Class Type for batches
AND obtab = c_mch1 " MCH1 = Object Table for batches
AND objek = zi_objek. " INOB object
ENDSELECT.
za_objek+0(18) = z_cuobj. " Reformat due to type conflicts
SELECT atinn atwrt atflv FROM ausp
INTO TABLE t_charac
WHERE objek = za_objek
AND atinn IN (z_lobm_mbdat,
z_zrfc_freeze_complete_time_hr).
SORT t_charac BY atinn atwrt.
Save this batch's availability date
CLEAR: t_charac.
READ TABLE t_charac WITH KEY atinn = z_lobm_mbdat
BINARY SEARCH.
IF sy-subrc = 0.
<b>lt_mchb</b>-avail_date = t_charac-atflv.
ENDIF.
Save this batch's freeze time
CLEAR: t_charac.
READ TABLE t_charac
WITH KEY atinn = z_zrfc_freeze_complete_time_hr
BINARY SEARCH.
IF sy-subrc = 0.
<b>lt_mchb</b>-freeze_time = t_charac-atflv.
ENDIF.
MODIFY <b>lt_mchb</b>.
ENDLOOP.
ENDFORM. "f1100_get_characteristics
Thanks,
Naren
Message was edited by: Narendran Muthukumaran
Message was edited by: Narendran Muthukumaran
10-24-2006 10:27 PM
Thanks Naren.
But in the perform statement you are not specifying any other internal table else it_mchb.
Can you pleae explain one sceanoro as how it works.
Thanks again for your help.
Shejal Shetty.
10-24-2006 10:59 PM
In the modifications that u have made, i have changes the following,
FORM f1100_get_characteristics
CHANGING lt_mchd LIKE it_mchb .
to
FORM f1100_get_characteristics
CHANGING lt_mchd LIKE <b>it_mchb[]</b> .
but it is giving me an error.
In PERFORM "F1100_GET_CHARACTERISTICS", the actual parameter "IT1_MCHB"
and formal parameter "lt_mchd" are incompatible. "IT1_MCHB" is the
header line of table "IT1_MCHB[]".
Any suggestions.
10-25-2006 3:48 AM
Hi
Just for your information:
FORM f1100_get_characteristics <b>CHANGING</b> lt_mchd LIKE <b>it_mchb[]</b> .
Above statement is same as below:
FORM f1100_get_characteristics <b>TABLES</b> lt_mchd LIKE <b>it_mchb</b>.
Naren has adviced w.r.t to work area, in your case i guess you need it as internal table. So both statements above will work.
Kind Regards
Eswar
10-24-2006 10:30 PM
Hi,
You want to use the same subroutine for some logic but for different internal tables right??
it1_mchb
it2_mchb
it3_mchb
That is the reason that I passed only the internal table..Do you want other parameters that needs to be passed from the subroutine???
Thanks,
Naren
10-24-2006 10:33 PM
All i want is to Modify IT1_mchb, IT2_mchb, IT3_mchb.
But using the perform statement.
I mean i want to loop through this internal tables and modify them.
In the form Endform I have used it_mchb but i dont have any internal table with that name.
Do u want me to create an Internal table with it_mchb and keep it blank.
Shejal.
10-24-2006 10:39 PM
Hi,
I got you what you are asking..If there is no internal table name like IT_MCHB use the internal table IT1_MCHB..Since all the three internal table are of the same structure..
FORM f1100_get_characteristics
CHANGING lt_mchd LIKE <b>it1_mchb</b>.
Thanks,
Naren
10-24-2006 10:45 PM
10-24-2006 11:02 PM
Hi,
How you have declared the internal table it1_mchb??
THanks,
Naren
10-24-2006 11:12 PM
BEGIN OF it_mchb OCCURS 0, " Batch Stock records
matnr LIKE mchb-matnr,
werks LIKE mchb-werks,
lgort LIKE mchb-lgort,
charg LIKE mchb-charg,
cspem LIKE mchb-cspem,
avail_date(8) TYPE n,
freeze_time(2) TYPE n,
END OF it_mchb,
it1_mchb LIKE it_mchb OCCURS 0 WITH HEADER LINE,
it2_mchb LIKE it_mchb OCCURS 0 WITH HEADER LINE,
it3_mchb LIKE it_mchb OCCURS 0 WITH HEADER LINE,
it4_mchb LIKE it_mchb OCCURS 0 WITH HEADER LINE,
PERFORM f1100_get_characteristics CHANGING it1_mchb.
PERFORM f1100_get_characteristics CHANGING it2_mchb.
PERFORM f1100_get_characteristics CHANGING it3_mchb.
PERFORM f1100_get_characteristics CHANGING it4_mchb.
FORM f1100_get_characteristics CHANGING rt_it_mchb LIKE it_mchb[].
DATA : wa_mchb LIKE it_mchb.
LOOP AT rt_it_mchb.
CLEAR: t_charac, za_objek, zi_objek, z_cuobj.
REFRESH: t_charac.
zi_objek+0(18) = rt_it_mchb-matnr. " Material
zi_objek+18(10) = rt_it_mchb-charg. " Batch Number
-
error message
In PERFORM "F1100_GET_CHARACTERISTICS", the actual parameter "IT1_MCHB"
and formal parameter "RT_IT_MCHB" are incompatible. "IT1_MCHB" is the
header line of table "IT1_MCHB[]".
Thanks,
10-24-2006 11:18 PM
Hi,
Do the following changes..
I removed the occurs 0..
BEGIN OF it_mchb, " Batch Stock records
I used it1_mchb instead of it_mchb.
FORM f1100_get_characteristics CHANGING rt_it_mchb LIKE it1_mchb
Hope this helps..
Thanks,
Naren
10-24-2006 11:21 PM
Hi,
I am sorry for the confusion..
Try this..
Remove the occurs 0
BEGIN OF it_mchb, " Batch Stock records
matnr LIKE mchb-matnr,
werks LIKE mchb-werks,
lgort LIKE mchb-lgort,
charg LIKE mchb-charg,
cspem LIKE mchb-cspem,
avail_date(8) TYPE n,
freeze_time(2) TYPE n,
END OF it_mchb,
it1_mchb LIKE it_mchb OCCURS 0 WITH HEADER LINE,
it2_mchb LIKE it_mchb OCCURS 0 WITH HEADER LINE,
it3_mchb LIKE it_mchb OCCURS 0 WITH HEADER LINE,
it4_mchb LIKE it_mchb OCCURS 0 WITH HEADER LINE.
used TABLES instead of CHANGING..
PERFORM f1100_get_characteristics TABLES it1_mchb.
PERFORM f1100_get_characteristics TABLES it2_mchb.
PERFORM f1100_get_characteristics TABLES it3_mchb.
PERFORM f1100_get_characteristics TABLES it4_mchb.
FORM f1100_get_characteristics TABLES rt_it_mchb structure it_mchb.
Thanks,
Naren