(Current design)
Batch is retrieved from LIPS-CHARG
Vendor batch is retrieved from LIPS-LICHN
(If there is no record in LIPS, blank will be printed out for both fields)
REQUIREMENT:
Batch is retrieved from LIPS-CHARG
Vendor batch is retrieved from LIPS-LICHN only if LIPS-LICHN is not blank.
If LIPS-LICHN is blank, vendor batch is retrieved from LIPS-CHARG.
(If there is no record in LIPS, blank will be printed out for both fields. If both LIPS-CHARG and LIPS-LICHN are blank, blank will be printed out for both fields)
t-lips is the internal table :
DATA: BEGIN OF t_lips OCCURS 0,
vbeln LIKE lips-vbeln, "Delivery document no
posnr LIKE lips-posnr, "Item number for Delivery document
charg LIKE lips-charg, "Batch number
lichn LIKE lips-lichn, "Vendor Batch number
END OF t_lips.
Following is the piece of code:
&----
*& Form f_collect_final
&----
Routine to collect all the display data into the final internal
table t_display.
----
FORM f_collect_final.
DATA: l_std_pac_no LIKE eket-menge,
l_std_pac_no_out(13) TYPE p,
l_tot_std_pt(13) TYPE c,
l_rmdr(13) TYPE n,
l_qtnt(13) TYPE n,
l_tabix TYPE i.
LOOP AT t_eket.
t_display-ebeln = t_eket-ebeln.
t_display-ebelp = t_eket-ebelp.
t_display-etens = t_eket-etens.
t_display-eindt = t_eket-eindt.
t_display-menge = t_eket-menge.
t_display-meins = t_eket-meins.
t_display-matnr = t_eket-matnr.
mod begin CR1591
t_display-maktx = t_eket-maktx.
READ TABLE t_makt WITH KEY matnr = t_eket-matnr
BINARY SEARCH.
IF sy-subrc = 0.
t_display-maktx = t_makt-maktx.
ENDIF.
mod end CR1591
t_display-vpnam = t_eket-vpnam.
t_display-lifnr = t_eket-lifnr.
t_display-charg = t_eket-charg.
READ TABLE t_mlgn WITH KEY matnr = t_eket-matnr
BINARY SEARCH.
IF sy-subrc = 0.
t_display-lhmg1 = t_mlgn-lhmg1.
t_display-lhme1 = t_mlgn-lhme1.
t_display-lety1 = t_mlgn-lety1.
t_display-ltkze = t_mlgn-ltkze.
ENDIF.
READ TABLE t_marm WITH KEY matnr = t_eket-matnr
BINARY SEARCH.
IF sy-subrc = 0.
t_display-umrez = t_marm-umrez.
t_display-meinh = t_eket-meins.
ENDIF.
READ TABLE t_marc WITH KEY matnr = t_eket-matnr
BINARY SEARCH.
IF sy-subrc = 0.
t_display-zzjp_nyu_sop = t_marc-zzjp_nyu_sop.
t_display-zzjp_dos_frm = t_marc-zzjp_dos_frm.
t_display-zzjp_aprn = t_marc-zzjp_aprn.
t_display-zzjp_re1 = t_marc-zzjp_re1.
ENDIF.
READ TABLE t_lfa1 WITH KEY lifnr = t_eket-lifnr
BINARY SEARCH.
IF sy-subrc = 0.
t_display-name1 = t_lfa1-name1.
ENDIF.
READ TABLE t_lips WITH KEY vbeln = t_eket-vbeln
posnr = t_eket-vbelp
BINARY SEARCH.
l_tabix = sy-tabix.
IF sy-subrc = 0.
t_display-charg = t_lips-charg.(I think this is the place to change).
t_display-lichn = t_lips-charg.
ENDIF.
I have tried with the following code, but it is not working.
IF sy-subrc = 0.
t_display-charg = t_lips-charg.
IF not t_lips-lichn is initial.
t_display-lichn = t_lips-lichn.
ELSE.
t_display-lichn = t_lips-charg.
ENDIF.
ENDIF.