‎2006 Sep 26 11:36 AM
hi friends, i have taken plant as select options and passed it to function module, using selopt...but i am getting an error 'length of plant is incorrect.
if i check the DDIC, the length of plant is 4. I am passing selopt which is of diff length..can any body pls explain
‎2006 Sep 26 11:39 AM
THE STRUCTURE SELOPT will have its own length.Can you specify where you have specified the plant.
‎2006 Sep 26 11:39 AM
‎2006 Sep 26 11:45 AM
hi Shakir,
use this like
*--Selection screen.
SELECTION-SCREEN BEGIN OF BLOCK ONE WITH FRAME TITLE TEXT-001.
PARAMETERS : P_WERKS TYPE WERKS_D obligatory, "Plant
P_LGORT TYPE LGORT_D. "Storage Location
SELECT-OPTIONS: S_BUDAT FOR SY-DATUM. "Date
SELECTION-SCREEN END OF BLOCK ONE.
*-- start of selection.
START-OF-SELECTION.
DATA : O_INV TYPE REF TO LCL_INV_VAR.
CREATE OBJECT O_INV.
*--Call method for selecting the data
CALL METHOD O_INV->SELECT_INV_DATA
EXPORTING
E_WERKS = P_WERKS
E_LGORT = P_LGORT
E_BUDAT = S_BUDAT[].
****************************
CLASS LCL_INV_VAR DEFINITION.
*--Public Section
PUBLIC SECTION.
*--Internal table Declaration
DATA : IT_INV_IN TYPE T_INV,
IT_INV_OUT TYPE T_INV.
*--Structure Declaration
DATA : X_BUDAT TYPE RANGE_DATE,
X_INV TYPE TY_INV.
*--Variable declaration
DATA : V_LDATE TYPE SY-DATUM, "low date
V_HDATE TYPE SY-DATUM, "high date
V_MEINS TYPE MEINS,
V_TABIX TYPE SY-TABIX,
V_TOTIN TYPE MENGE_D,
V_TOTOUT TYPE MENGE_D,
V_NETTOT TYPE MENGE_D.
*--Method Declaration
METHODS :
*--Method for selecting data
SELECT_INV_DATA IMPORTING E_WERKS TYPE WERKS_D
E_LGORT TYPE LGORT_D
E_BUDAT TYPE T_T_DATE .
ENDCLASS. "lcl_inv_var DEFINITION
*----------------------------------------------------------------------*
* CLASS lcl_inv_var IMPLEMENTATION
*----------------------------------------------------------------------*
CLASS LCL_INV_VAR IMPLEMENTATION.
*--Method SELECT_INV_DATA implementation
METHOD SELECT_INV_DATA .
*--Type declaration
TYPES : BEGIN OF TY_MKPF,
MBLNR TYPE MBLNR,
MJAHR TYPE MJAHR,
END OF TY_MKPF ,
T_MKPF TYPE STANDARD TABLE OF TY_MKPF.
*--Internal table declaration.
DATA : IT_MKPF TYPE T_MKPF.
*--Selecting data for inventory IN movement type 311 and 101 where the
* selected storage location is destination storage location in MSEG.
SELECT MBLNR MJAHR
INTO TABLE IT_MKPF
FROM MKPF
WHERE BUDAT IN E_BUDAT.
IF NOT IT_MKPF IS INITIAL.
SELECT BWART MATNR MENGE
MEINS
FROM MSEG
INTO TABLE IT_INV_IN
FOR ALL ENTRIES IN IT_MKPF
WHERE BWART IN ('311' , '101')
AND WERKS = E_WERKS
AND LGORT = E_LGORT
AND SHKZG = CON_S
AND MBLNR = IT_MKPF-MBLNR
AND MJAHR = IT_MKPF-MJAHR.
*--Delete all the entries from the table IT_INV_IN where unit of measure
*is not PC
DELETE IT_INV_IN WHERE MEINS <> 'ST'.
*--Selecting data for inventory OUT movement type 311,261,551 and 201
*where the
* selected storage location is Source storage location in MSEG.
SELECT BWART MATNR MENGE
MEINS
FROM MSEG
INTO TABLE IT_INV_OUT
FOR ALL ENTRIES IN IT_MKPF
WHERE BWART IN ('261' , '311' , '551' , '201')
AND WERKS = E_WERKS
AND LGORT = E_LGORT
AND SHKZG = CON_H
AND MBLNR = IT_MKPF-MBLNR
AND MJAHR = IT_MKPF-MJAHR.
*--Delete all the entries from the table IT_INV_OUT where unit of
*measure is not PC
DELETE IT_INV_OUT WHERE MEINS <> 'ST'.
ENDIF.
ENDMETHOD. "select_inv_data
Regards,
Richa
‎2006 Sep 26 11:56 AM
hi
good
change the lengh of the plant as 4 and than check the difference,i hope it ll work.
thanks
mrutyun^
‎2006 Sep 26 11:57 AM
Hi all, tahnku v much for ur responses...
my main prog code in se38 is REPORT Z_NEW.
tables : mard,
marc,
mbew,
makt.
parameters : material like mara-matnr.
select-options plant for marc-werks.
data : begin of itab1 occurs 0.
include structure mard.
data : end of itab1.
data : begin of itab2 occurs 0.
include structure marc.
data : end of itab2.
data : begin of itab3 occurs 0.
include structure mbew.
data : end of itab3.
data : begin of itab4 occurs 0.
include structure makt.
data : end of itab4.
CALL FUNCTION 'Z_NEW1'
EXPORTING
MATNR = MATERIAL
TABLES
IMARD1 = ITAB1
IMARC1 = ITAB2
IMBEW1 = ITAB3
WERKS = PLANT
IMAKT1 = ITAB4.
*Table to output
data : begin of itab5 occurs 0,
lgort like mard-lgort,
labst like mard-labst,
dismm like marc-dismm,
dispo like marc-dispo,
stprs like mbew-stprs,
vmver like mbew-vmver,
maktx like makt-maktx,
end of itab5.
sort :itab1 by matnr,
itab3 by matnr,
itab4 by matnr.
loop at itab2.
read table itab1 with key matnr = itab2-matnr
binary search.
if sy-subrc eq 0.
move itab1-lgort to itab5-lgort.
move itab1-labst to itab5-labst.
endif.
read table itab3 with key matnr = itab2-matnr
binary search.
if sy-subrc eq 0.
move itab3-stprs to itab5-stprs.
move itab3-vmver to itab5-vmver.
endif.
read table itab4 with key matnr = itab4-matnr
binary search.
if sy-subrc eq 0.
move itab4-maktx to itab5-maktx.
endif.
if not itab5[] is initial.
append itab5.
endif.
endloop.
loop at itab5.
write : /
itab5-lgort,
itab5-labst,
itab5-dismm,
itab5-dispo,
itab5-stprs,
itab5-vmver,
itab5-maktx.
endloop.
and in se37, FM is :
select lgort labst
from mard
into corresponding fields of table imard1
where werks in werks and
matnr = matnr.
select dismm dispo
from marc
into corresponding fields of table imarc1
*where werks in werks and
where matnr = matnr.
select stprs vmver
from mbew
into corresponding fields of table imbew1
where matnr = matnr.
select maktx
from makt
into corresponding fields of table imakt1
where matnr = matnr.
.....
in tables in fm i gave werks like selopt and also defined imard1, imarc1, imbew1 and imakt1..pls check...
‎2006 Sep 26 12:05 PM
U can try either of the below options as the problem is due to difference in the lenght.
Option 1.
Calling ABAP.
data : lplant(24) type c.
select-options : plant for lplant.
Option 2.
Function Module.
Define a range for w_plant for marc-werks.
and populate the data from the paramater table WERKS to the range W_plant.
Regards
Anurag
‎2006 Sep 26 12:12 PM
Hi,
what is the dataelement for werks in the FM and its length.and the length of werks in the select options.
regards
Ahasan
‎2006 Sep 26 12:12 PM
give the whole bodyof plant and try
chk code in bold
CALL FUNCTION 'Z_NEW1'
EXPORTING
MATNR = MATERIAL
TABLES
IMARD1 = ITAB1
IMARC1 = ITAB2
IMBEW1 = ITAB3
WERKS = <b>PLANT[]</b>
IMAKT1 = ITAB4.
‎2006 Sep 26 12:11 PM
Hi,
make chanhes relevent to populate new fields value in
copied driver program
assign driver program to output type using
NAce or nact transaction so that entry exist in table
TNAPR
Regards
amole
‎2006 Sep 26 12:14 PM
Hi,
disregard my earlier mail.
problem is due to length of werks(4) field
snd selopt low value(24)
use below logic in FM
ranges r_werks for t001w-werks.
select * from mard where matnr in s_matnr
werks in r_werks.
Regards
amole
‎2006 Sep 26 12:16 PM
Hi Shakir,
Since you have defined the Select Option for Werks the High and Low fields in the select option get set to length '4' as that of Werks.
However the SELOPT structure has a definition of Char 24 for High and Low. Hence the conflict.
To avoid this you can do the following in your program;
**********************************
data: pl1 type table of selopt.
pl1[] = plant[].
Pass pl1 to your FM instead of plant
**********************************
Hope this helps.
Regards.
‎2006 Sep 28 7:55 AM
thanks guys!!...the issue has been resolved..i used werks like selopt in FM, nd defined plant1 length as 24 before using it as select option in se38. i am tring to reward points but the site is givin error...but i will keep trying...
Cheers !!