How to add the plant code to BUS1001

Hans Brilleman Hans.Brilleman at capetown.gov.za
Fri Jun 20 04:50:44 EDT 2003


Hi Tony,
 
I have gone through your code, but am confused at what you are trying
to do. Firstly I agree with Kjetilk about switching the fields around.
Secondly I am not sure why you are reading table MARC, because if I
understand you correctly, you are trying to obtain the plant, but you
are reading table MARC with a plant code. Where are you getting this
plant code from, and why are you then still reading the table?
 
If you are trying to obtain the plant code, table MARC would not be the
right table to use as this table stores all the materials per plant. If
you only have the material code, you will not find the correct plant.
 
In this case you must rather see if you have a document nr e.g.  PO nr
or Purch req nr, and then get the plant code from the actual document.
 
Just a suggestion (this is if I understood you correct)
 
Hans.
 
>>> AHoodak at Gleason.com 06/19/03 09:08pm >>>
Greetings folks -
 
I have a BO ZBUS1001 which is a subtype of BUS1001. I need to add a
plant
attribute to this subtype. I have done the following:
 
For an attribute, I did the following
 
Attribute             Plant2
Object type           ZBUS1001
Release               45B
Status                released
 
 
 Name                 Plant2
 Description          Plant2
 
Set up as a virtual attribute and the data type reference is set to
ABAP
dictionary with the reference table and field being:
 
 
   Reference table    MARC
   Reference field    WERKS
 
 
In my program code, I have the following:
 
*****           Implementation of object type ZBUS1001
*****
INCLUDE <object>.
begin_data object. " Do not change.. DATA is generated
* only private members may be inserted into structure private
DATA:
" begin of private,
"   to declare private attributes remove comments and
"   insert private attributes here ...
" end of private,
  BEGIN OF key,
      material LIKE mara-matnr,
  END OF key,
      plant2 LIKE marc-werks,
      _marc LIKE marc.
end_data object. " Do not change.. DATA is generated
 
TABLES marc.
*
get_table_property marc.
DATA subrc LIKE sy-subrc.
* Fill TABLES MARC to enable Object Manager Access to Table Properties
  PERFORM select_table_marc USING subrc.
  IF subrc NE 0.
    exit_object_not_found.
  ENDIF.
end_property.
*
* Use Form also for other(virtual) Properties to fill TABLES MARC
FORM select_table_marc USING subrc LIKE sy-subrc.
*DATA v_werks LIKE marc-werks.
*swc_get_element container 'Plant' v_werks.
* Select single * from MARC, if OBJECT-_MARC is initial
BREAK-POINT.
  IF object-_marc-mandt IS INITIAL
  AND object-_marc-matnr IS INITIAL
  AND object-_marc-werks IS INITIAL.
    SELECT SINGLE * FROM marc CLIENT SPECIFIED
        WHERE mandt = sy-mandt
        AND matnr = object-key-material
      AND werks = 2000
*        AND plant2 = 2000.
     AND object-plant2 = werks.
    subrc = sy-subrc.
    IF subrc NE 0. EXIT. ENDIF.
    object-_marc = marc.
  ELSE.
    subrc = 0.
    marc = object-_marc.
  ENDIF.
ENDFORM.
 
 
 
get_property plant2 changing container.
  swc_set_element container 'Plant2' object-plant2.
end_property.
 
 
 
The problem is - in my code I keep getting the error "Field
"OBJECT-PLANT2"
unknown" for the above underlined line (PS - I am not a seasoned
ABAPer, so
I am just getting my feet wet here).
 
The problem is also, I am not getting the plant2 attribute populated
when I
run a test. The attribute comes back blank. So I tried forcing the
variable
"WERKS" to be populated with "2000" just to see if the value comes
through.
Anyways - this is my approach and I am sure that I am close, but
something
is not as I expected. So if you get a free minutes, please send me a
line
and let me know what I am doing wrong here. I look forward to a bit of
guidance.
 
Thanks so much in advance!
 
Tony
 


More information about the SAP-WUG mailing list