WHERE - (cond_syntax)

SAP/ABAP 개발 2010. 11. 17. 08:15 Posted by KindKay

    data: cond_syntax type string.

  clear: cond_syntax

  case pa_werks.
    when 'P100'.
      lr_vstel-low = 'H110'.
      concatenate ' ( D~AUART LIKE ' '''' 'ZCD%' ''''
             into cond_syntax.
      concatenate cond_syntax 'OR D~AUART LIKE ' '''' 'ZEX%' ''''
             into cond_syntax.
      concatenate cond_syntax 'OR D~AUART LIKE ' '''' 'ZFB%' ''''
             into cond_syntax.
      concatenate cond_syntax 'OR D~AUART LIKE ' '''' 'ZFD%' ''''
             into cond_syntax.
      concatenate cond_syntax 'OR D~AUART LIKE ' '''' 'ZOR%' '''' ' )'
             into cond_syntax.
    when 'P200'.
      lr_vstel-low = 'H210'.
      concatenate ' D~AUART EQ ' '''' 'ZA1' ''''
             into cond_syntax.
  endcase.

  select a~edatu c~kunnr  a~vbeln a~posnr b~route
         b~matnr b~kwmeng b~zieme b~werks a~wmeng
    into corresponding fields of table gt_base
    from vbep as a inner join vbap as b
                           on a~vbeln eq b~vbeln
                          and a~posnr eq b~posnr
                   inner join vbpa as c
                           on a~vbeln eq c~vbeln
                          and c~parvw eq 'WE'     "Ship-to-party(SH)
                   inner join vbak as d
                           on a~vbeln eq d~vbeln
                   inner join mara as e
                           on b~matnr eq e~matnr
   where a~edatu in s_edatu
     and a~vbeln in s_vbeln
     and b~matnr in s_matnr
     and c~kunnr in s_kunnr
     and b~kwmeng ne ''
     and (cond_syntax).