cancel
Showing results for 
Search instead for 
Did you mean: 

List of plants

Former Member
0 Kudos
191

Is there a BAPI available to get list of plants?

Accepted Solutions (0)

Answers (3)

Answers (3)

ferry_lianto
Active Contributor
0 Kudos

Hi Krishna,

Please try FM <b>K_ABC_GET_WERKS_FOR_BUKRS</b> to get plants based on company code.

Hope this will help.

Regards,

Ferry Lianto

Please reward points if helpful.

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

Here is another RFC FM.



report zrich_0001.

data: it001w type table of t001w with header line.

call function '/SAPNEA/SMAPI_PLANT_GETLIST'
     tables
          plant_top = it001w.


loop at it001w.
  write:/ it001w-werks, it001w-name1.
endloop.

Regards,

Rich Heilman

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

I'm not finding any BAPI yet. But you can achieve the same using this code.



report zrich_0001.

data: iopt type table of rfc_db_opt with header line.
data: ifld type table of rfc_db_fld with header line.
data: idat type table of tab512 with header line.

ifld-fieldname = 'WERKS'. append ifld.
ifld-fieldname = 'NAME1'. append ifld.


call function 'RFC_READ_TABLE'
  exporting
    query_table                = 'T001W'
    delimiter                  = ','
*   NO_DATA                    = ' '
*   ROWSKIPS                   = 0
*   ROWCOUNT                   = 0
  tables
    options                    = iopt
    fields                     = ifld
    data                       = idat
 exceptions
   table_not_available        = 1
   table_without_data         = 2
   option_not_valid           = 3
   field_not_valid            = 4
   not_authorized             = 5
   data_buffer_exceeded       = 6
   others                     = 7.

loop at idat.
  write:/ idat.
endloop.


Regards,

Rich Heilman