Skip to Content
0
Jun 18, 2015 at 01:08 PM

how bring correct status field to output internal table for each production order

86 Views

Hi All,

I want to bring Status field from Tcode COOIS for each production order. I have written the following code.

I am able to get the status to variant g_txt04 . But i want the status for each order. I want to know how to connect between i_prod_order and g_txt04.

i_prod_order has objnr and zztxt04. i want to bring g_txt04 value to zztxt04.


FORM 0prodorder_attr_enhancements TABLES p_data.

DATA: i_prod_order TYPE ppord_bw.

DATA: BEGIN OF set_stat OCCURS 0.

INCLUDE STRUCTURE jstat.

DATA: END OF set_stat.

DATA: BEGIN OF lit_usrtxt OCCURS 0, "User Status text - TJ02T

objnr LIKE JEST-OBJNR,

ISTAT LIKE TJ02T-ISTAT,

txt04 LIKE TJ02T-txt04,

END OF lit_usrtxt.

DATA: wa_lit_usrtxt LIKE lit_usrtxt.

data : g_txt04 type string.

LOOP AT p_data INTO i_prod_order.

SELECT SINGLE ltrmi

FROM afpo

INTO i_prod_order-zzgltri

WHERE aufnr = i_prod_order-aufnr.

SELECT SINGLE gstrp "Basic Start date

gltrp "Basic Finish date

erdat "Created on date

gstri "Actual Start Date

igmng "Confirmed Quantity

gamng "Total order quantity

gmein "Base unit of measure

objnr

FROM caufv

INTO (i_prod_order-zzgstrp,

i_prod_order-zzgltrp,

i_prod_order-zzerdat,

i_prod_order-zzgstri,

i_prod_order-zzdelqty,

i_prod_order-zzordqty,

i_prod_order-zzgmein,

i_prod_order-zzobjnr)

WHERE aufnr = i_prod_order-aufnr.

IF i_prod_order-plnbez IS INITIAL.

SELECT SINGLE stlbez

FROM afko

INTO i_prod_order-plnbez

WHERE aufnr = i_prod_order-aufnr.

IF i_prod_order-plnbez IS INITIAL.

SELECT SINGLE matnr

INTO i_prod_order-plnbez

FROM afpo

WHERE aufnr = i_prod_order-aufnr.

ENDIF.

ENDIF.

* Gets status code from Table JEST

call function 'STATUS_READ'

exporting

objnr = i_prod_order-zzobjnr

only_active = 'X'

tables

status = set_stat

exceptions

object_not_found = 01

others = 02.

If SY-SUBRC <> '0'.

ENDIF.

* Gets status desc from TJ02T

SELECT DISTINCT

txt04 FROM TJ02T

INTO TABLE lit_usrtxt

FOR ALL ENTRIES IN set_stat

where ISTAT = set_stat-STAT

AND spras = sy-langu.

LOOP AT lit_usrtxt INTO WA_lit_usrtxt.

concatenate g_txt04 '' WA_lit_usrtxt into g_txt04 separated by space.

ENDLOOP.

MODIFY p_data FROM i_prod_order.

ENDLOOP.

ENDFORM. "0prodorder_attr_enhancements



My requirement is how to assign g_txt04 value to i_prod_order-zztxt04. (i_prod_order has objnr and zztxt04.)


rgds,

Rathinakumar

Message was edited by: Rathinakumar Kumarasamy