How to add the plant code to BUS1001

Hoodak, Anthony J. AHoodak at Gleason.com
Thu Jun 19 15:08:10 EDT 2003


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