1. 기말재고 수량을 조회시 MMBE, MB52는 너무 느려서 만듬.
*-- Table types ZTT_MM_MARD / ZST_MM_MARD WERKS WERKS_D CHAR MATNR MATNR CHAR LGORT LGORT_D CHAR LABST LABST QUAN MARA MEINS INSME INSME QUAN MARA MEINS SPEME SPEME QUAN MARA MEINS LFGJA LFGJA NUMC LFMON LFMON NUMC ZTT_MM_MSLB / ZST_MM_MSLB WERKS WERKS_D CHAR MATNR MATNR CHAR CHARG CHARG_D CHAR LIFNR LIFNR CHAR SOBKZ SOBKZ CHAR LBLAB LABST QUAN MARA MEINS LBINS INSME QUAN MARA MEINS LFGJA LFGJA NUMC LFMON LFMON NUMC ZTT_MM_MSKU / ZST_MM_MSKU WERKS WERKS_D CHAR MATNR MATNR CHAR CHARG CHARG_D CHAR SOBKZ SOBKZ CHAR KUNNR KUNNR CHAR KULAB LABST QUAN MARA MEINS KUINS INSME QUAN MARA MEINS LFGJA LFGJA NUMC LFMON LFMON NUMC ZTT_MM_MSKA / ZST_MM_MSKA WERKS WERKS_D CHAR MATNR MATNR CHAR CHARG CHARG_D CHAR LGORT LGORT_D CHAR SOBKZ SOBKZ CHAR VBELN VBELN CHAR POSNR POSNR NUMC KALAB LABST QUAN MARA MEINS KAINS INSME QUAN MARA MEINS KASPE SPEME QUAN MARA MEINS LFGJA LFGJA NUMC LFMON LFMON NUMC ZTT_MM_MARC / ZST_MM_MARC WERKS WERKS_D CHAR MATNR MATNR CHAR TRAME TRAME QUAN MARA MEINS LFGJA LFGJA NUMC LFMON LFMON NUMC ZTT_MM_MCHB / ZST_MM_MCHB WERKS WERKS_D CHAR MATNR MATNR CHAR CHARG CHARG_D CHAR LGORT LGORT_D CHAR CLABS LABST QUAN MARA MEINS CINSM INSME QUAN MARA MEINS CSPEM SPEME QUAN MARA MEINS LFGJA LFGJA NUMC LFMON LFMON NUMC ZTT_MM_MKOL / ZST_MM_MKOL WERKS WERKS_D CHAR MATNR MATNR CHAR LGORT LGORT_D CHAR CHARG CHARG_D CHAR SOBKZ SOBKZ CHAR LIFNR LIFNR CHAR SLABS LABST QUAN MARA MEINS SINSM INSME QUAN MARA MEINS SSPEM SPEME QUAN MARA MEINS LFGJA LFGJA NUMC LFMON LFMON NUMC *-- Range tables ZRANGES_LIFNR ZRANGES_KUNNR
FUNCTION zmm_get_stock. FUNCTION zmm_get_stock. *"---------------------------------------------------------------------- *"*"Local Interface: *" IMPORTING *" VALUE(IV_ZTABNAME) TYPE CHAR10 *" VALUE(IV_SPMON) TYPE SPMON *" VALUE(IT_WERKS) TYPE RANGE_T_WERKS_D OPTIONAL *" VALUE(IT_MATNR) TYPE RANGES_MATNR OPTIONAL *" VALUE(IT_LGORT) TYPE RANGE_T_LGORT_D OPTIONAL *" VALUE(IT_LIFNR) TYPE ZRANGES_LIFNR OPTIONAL *" VALUE(IT_KUNNR) TYPE ZRANGES_KUNNR OPTIONAL *" EXPORTING *" VALUE(ET_MARD) TYPE ZTT_MM_MARD *" VALUE(ET_MSLB) TYPE ZTT_MM_MSLB *" VALUE(ET_MSKU) TYPE ZTT_MM_MSKU *" VALUE(ET_MSKA) TYPE ZTT_MM_MSKA *" VALUE(ET_MARC) TYPE ZTT_MM_MARC *" VALUE(ET_MKOL) TYPE ZTT_MM_MKOL *" VALUE(ET_MCHB) TYPE ZTT_MM_MCHB *"---------------------------------------------------------------------- CLEAR : et_mard[], et_mslb[], et_mska[], et_msku[], et_marc[]. IF iv_ztabname IS INITIAL OR iv_spmon IS INITIAL. EXIT. ENDIF. CASE iv_ztabname. *--- General Stock WHEN 'MARD'. PERFORM get_mard USING iv_spmon it_werks[] it_matnr[] it_lgort[] CHANGING et_mard[]. *--- Special Stocks with Vendor WHEN 'MSLB'. PERFORM get_mslb USING iv_spmon it_werks[] it_matnr[] it_lifnr[] CHANGING et_mslb[]. *--- Sales Order Stock WHEN 'MSKA'. PERFORM get_mska USING iv_spmon it_werks[] it_matnr[] it_lgort[] CHANGING et_mska[]. *--- Special Stocks with Customer WHEN 'MSKU'. PERFORM get_msku USING iv_spmon it_werks[] it_matnr[] it_kunnr[] CHANGING et_msku[]. *--- Plant Stock WHEN 'MARC'. PERFORM get_marc USING iv_spmon it_werks[] it_matnr[] CHANGING et_marc[]. *--- Special Stock from Vendor WHEN 'MKOL'. PERFORM get_mkol USING iv_spmon it_werks[] it_matnr[] it_lgort[] CHANGING et_mkol[]. *--- Batch Stocks WHEN 'MCHB'. PERFORM get_mchb USING iv_spmon it_werks[] it_matnr[] it_lgort[] CHANGING et_mchb[]. ENDCASE. ENDFUNCTION. *&---------------------------------------------------------------------* *& Form get_mard *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * -->PV_MONTH text * -->PT_WERKS text * -->PT_MATNR text * -->PT_LGORT text * -->PT_MARD text *----------------------------------------------------------------------* FORM get_mard USING pv_month TYPE spmon pt_werks TYPE range_t_werks_d pt_matnr TYPE ranges_matnr pt_lgort TYPE range_t_lgort_d CHANGING pt_mard TYPE ztt_mm_mard. DATA : lv_lfgja LIKE mard-lfgja, lv_lfmon LIKE mard-lfmon. lv_lfgja = pv_month+0(4). lv_lfmon = pv_month+4(2). SELECT a~werks a~matnr a~lgort a~labst a~insme a~speme a~lfgja a~lfmon APPENDING CORRESPONDING FIELDS OF TABLE pt_mard FROM mard AS a WHERE a~matnr IN pt_matnr AND a~werks IN pt_werks AND a~lgort IN pt_lgort AND a~lfgja = ( SELECT MAX( lfgja ) FROM mard WHERE matnr = a~matnr AND werks = a~werks AND lgort = a~lgort AND ( lfgja LT lv_lfgja OR ( lfgja EQ lv_lfgja AND lfmon LE lv_lfmon ) ) ) AND a~lfmon = ( SELECT MAX( lfmon ) FROM mard WHERE matnr = a~matnr AND werks = a~werks AND lgort = a~lgort AND ( ( lfgja EQ a~lfgja AND lfgja LT lv_lfgja ) OR ( lfgja EQ lv_lfgja AND lfmon LE lv_lfmon ) ) ) AND ( a~labst NE 0 OR a~insme NE 0 OR a~speme NE 0 ) %_HINTS ORACLE '&MAX_BLOCKING_FACTOR 20&'. SELECT a~werks a~matnr a~lgort a~labst a~insme a~speme a~lfgja a~lfmon APPENDING CORRESPONDING FIELDS OF TABLE pt_mard FROM mardh AS a WHERE a~matnr IN pt_matnr AND a~werks IN pt_werks AND a~lgort IN pt_lgort AND a~lfgja = ( SELECT MIN( lfgja ) FROM mardh WHERE matnr = a~matnr AND werks = a~werks AND lgort = a~lgort AND ( lfgja GT lv_lfgja OR ( lfgja EQ lv_lfgja AND lfmon GE lv_lfmon ) ) ) AND a~lfmon = ( SELECT MIN( lfmon ) FROM mardh WHERE matnr = a~matnr AND werks = a~werks AND lgort = a~lgort AND ( ( lfgja EQ a~lfgja AND lfgja GT lv_lfgja ) OR ( lfgja EQ lv_lfgja AND lfmon GE lv_lfmon ) ) ) AND ( a~labst NE 0 OR a~insme NE 0 OR a~speme NE 0 ) %_HINTS ORACLE '&MAX_BLOCKING_FACTOR 20&'. ENDFORM. "get_mard *&---------------------------------------------------------------------* *& Form get_mslb *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * -->PV_MONTH text * -->PT_WERKS text * -->PT_MATNR text * -->PT_LIFNR text * -->PT_MSLB text *----------------------------------------------------------------------* FORM get_mslb USING pv_month TYPE spmon pt_werks TYPE range_t_werks_d pt_matnr TYPE ranges_matnr pt_lifnr TYPE zranges_lifnr CHANGING pt_mslb TYPE ztt_mm_mslb. DATA : lv_lfgja LIKE mard-lfgja, lv_lfmon LIKE mard-lfmon. lv_lfgja = pv_month+0(4). lv_lfmon = pv_month+4(2). SELECT a~werks a~matnr a~lifnr a~sobkz a~lfgja a~lfmon a~charg a~lblab a~lbins APPENDING CORRESPONDING FIELDS OF TABLE pt_mslb FROM mslb AS a WHERE a~matnr IN pt_matnr AND a~werks IN pt_werks AND a~lifnr IN pt_lifnr AND a~lfgja = ( SELECT MAX( lfgja ) FROM mslb WHERE matnr = a~matnr AND werks = a~werks AND charg = a~charg AND sobkz = a~sobkz AND lifnr = a~lifnr AND ( lfgja LT lv_lfgja OR ( lfgja EQ lv_lfgja AND lfmon LE lv_lfmon ) ) ) AND a~lfmon = ( SELECT MAX( lfmon ) FROM mslb WHERE matnr = a~matnr AND werks = a~werks AND charg = a~charg AND sobkz = a~sobkz AND lifnr = a~lifnr AND ( ( lfgja EQ a~lfgja AND lfgja LT lv_lfgja ) OR ( lfgja EQ lv_lfgja AND lfmon LE lv_lfmon ) ) ) AND ( a~lblab NE 0 OR a~lbins NE 0 ) %_HINTS ORACLE '&MAX_BLOCKING_FACTOR 20&'. SELECT a~werks a~matnr a~lifnr a~sobkz a~lfgja a~lfmon a~charg a~lblab a~lbins APPENDING CORRESPONDING FIELDS OF TABLE pt_mslb FROM mslbh AS a WHERE a~matnr IN pt_matnr AND a~werks IN pt_werks AND a~lifnr IN pt_lifnr AND a~lfgja = ( SELECT MIN( lfgja ) FROM mslbh WHERE matnr = a~matnr AND werks = a~werks AND charg = a~charg AND sobkz = a~sobkz AND lifnr = a~lifnr AND ( lfgja GT lv_lfgja OR ( lfgja EQ lv_lfgja AND lfmon GE lv_lfmon ) ) ) AND a~lfmon = ( SELECT MIN( lfmon ) FROM mslbh WHERE matnr = a~matnr AND werks = a~werks AND charg = a~charg AND sobkz = a~sobkz AND lifnr = a~lifnr AND ( ( lfgja EQ a~lfgja AND lfgja GT lv_lfgja ) OR ( lfgja EQ lv_lfgja AND lfmon GE lv_lfmon ) ) ) AND ( a~lblab NE 0 OR a~lbins NE 0 ) %_HINTS ORACLE '&MAX_BLOCKING_FACTOR 20&'. ENDFORM. "get_mslb *&---------------------------------------------------------------------* *& Form get_msku *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * -->PV_MONTH text * -->PT_WERKS text * -->PT_MATNR text * -->PT_KUNNR text * -->PT_MSKU text *----------------------------------------------------------------------* FORM get_msku USING pv_month TYPE spmon pt_werks TYPE range_t_werks_d pt_matnr TYPE ranges_matnr pt_kunnr TYPE zranges_kunnr CHANGING pt_msku TYPE ztt_mm_msku. DATA : lv_lfgja LIKE mard-lfgja, lv_lfmon LIKE mard-lfmon. lv_lfgja = pv_month+0(4). lv_lfmon = pv_month+4(2). SELECT a~werks a~matnr a~charg a~sobkz a~kunnr a~lfgja a~lfmon a~kulab a~kuins APPENDING CORRESPONDING FIELDS OF TABLE pt_msku FROM msku AS a WHERE a~matnr IN pt_matnr AND a~werks IN pt_werks AND a~kunnr IN pt_kunnr AND a~lfgja = ( SELECT MAX( lfgja ) FROM msku WHERE matnr = a~matnr AND werks = a~werks AND charg = a~charg AND sobkz = a~sobkz AND kunnr = a~kunnr AND ( lfgja LT lv_lfgja OR ( lfgja EQ lv_lfgja AND lfmon LE lv_lfmon ) ) ) AND a~lfmon = ( SELECT MAX( lfmon ) FROM msku WHERE matnr = a~matnr AND werks = a~werks AND charg = a~charg AND sobkz = a~sobkz AND kunnr = a~kunnr AND ( ( lfgja EQ a~lfgja AND lfgja LT lv_lfgja ) OR ( lfgja EQ lv_lfgja AND lfmon LE lv_lfmon ) ) ) AND ( a~kulab NE 0 OR a~kuins NE 0 ) %_HINTS ORACLE '&MAX_BLOCKING_FACTOR 20&'. SELECT a~werks a~matnr a~charg a~sobkz a~kunnr a~lfgja a~lfmon a~kulab a~kuins APPENDING CORRESPONDING FIELDS OF TABLE pt_msku FROM mskuh AS a WHERE a~matnr IN pt_matnr AND a~werks IN pt_werks AND a~kunnr IN pt_kunnr AND a~lfgja = ( SELECT MIN( lfgja ) FROM mskuh WHERE matnr = a~matnr AND werks = a~werks AND charg = a~charg AND sobkz = a~sobkz AND kunnr = a~kunnr AND ( lfgja GT lv_lfgja OR ( lfgja EQ lv_lfgja AND lfmon GE lv_lfmon ) ) ) AND a~lfmon = ( SELECT MIN( lfmon ) FROM mskuh WHERE matnr = a~matnr AND werks = a~werks AND charg = a~charg AND sobkz = a~sobkz AND kunnr = a~kunnr AND ( ( lfgja EQ a~lfgja AND lfgja GT lv_lfgja ) OR ( lfgja EQ lv_lfgja AND lfmon GE lv_lfmon ) ) ) AND ( a~kulab NE 0 OR a~kuins NE 0 ) %_HINTS ORACLE '&MAX_BLOCKING_FACTOR 20&'. ENDFORM. "get_msku *&---------------------------------------------------------------------* *& Form get_mska *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * -->PV_MONTH text * -->PT_WERKS text * -->PT_MATNR text * -->PT_LGORT text * -->PT_MSKA text *----------------------------------------------------------------------* FORM get_mska USING pv_month TYPE spmon pt_werks TYPE range_t_werks_d pt_matnr TYPE ranges_matnr pt_lgort TYPE range_t_lgort_d CHANGING pt_mska TYPE ztt_mm_mska. DATA : lv_lfgja LIKE mard-lfgja, lv_lfmon LIKE mard-lfmon. lv_lfgja = pv_month+0(4). lv_lfmon = pv_month+4(2). SELECT a~werks a~matnr a~lgort a~sobkz a~lfgja a~lfmon a~charg a~vbeln a~posnr a~kalab a~kains a~kaspe APPENDING CORRESPONDING FIELDS OF TABLE pt_mska FROM mska AS a WHERE a~matnr IN pt_matnr AND a~werks IN pt_werks AND a~lgort IN pt_lgort AND a~lfgja = ( SELECT MAX( lfgja ) FROM mska WHERE matnr = a~matnr AND werks = a~werks AND lgort = a~lgort AND charg = a~charg AND sobkz = a~sobkz AND vbeln = a~vbeln AND posnr = a~posnr AND ( lfgja LT lv_lfgja OR ( lfgja EQ lv_lfgja AND lfmon LE lv_lfmon ) ) ) AND a~lfmon = ( SELECT MAX( lfmon ) FROM mska WHERE matnr = a~matnr AND werks = a~werks AND lgort = a~lgort AND charg = a~charg AND sobkz = a~sobkz AND vbeln = a~vbeln AND posnr = a~posnr AND ( ( lfgja EQ a~lfgja AND lfgja LT lv_lfgja ) OR ( lfgja EQ lv_lfgja AND lfmon LE lv_lfmon ) ) ) AND ( a~kalab NE 0 OR a~kains NE 0 OR a~kaspe NE 0 ) %_HINTS ORACLE '&MAX_BLOCKING_FACTOR 20&'. SELECT a~werks a~matnr a~lgort a~sobkz a~lfgja a~lfmon a~charg a~vbeln a~posnr a~kalab a~kains a~kaspe APPENDING CORRESPONDING FIELDS OF TABLE pt_mska FROM mskah AS a WHERE a~matnr IN pt_matnr AND a~werks IN pt_werks AND a~lgort IN pt_lgort AND a~lfgja = ( SELECT MIN( lfgja ) FROM mskah WHERE matnr = a~matnr AND werks = a~werks AND lgort = a~lgort AND charg = a~charg AND sobkz = a~sobkz AND vbeln = a~vbeln AND posnr = a~posnr AND ( lfgja GT lv_lfgja OR ( lfgja EQ lv_lfgja AND lfmon GE lv_lfmon ) ) ) AND a~lfmon = ( SELECT MIN( lfmon ) FROM mskah WHERE matnr = a~matnr AND werks = a~werks AND lgort = a~lgort AND charg = a~charg AND sobkz = a~sobkz AND vbeln = a~vbeln AND posnr = a~posnr AND ( ( lfgja EQ a~lfgja AND lfgja GT lv_lfgja ) OR ( lfgja EQ lv_lfgja AND lfmon GE lv_lfmon ) ) ) AND ( a~kalab NE 0 OR a~kains NE 0 OR a~kaspe NE 0 ) %_HINTS ORACLE '&MAX_BLOCKING_FACTOR 20&'. ENDFORM. "get_mska *&---------------------------------------------------------------------* *& Form get_marc *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * -->PV_MONTH text * -->PT_WERKS text * -->PT_MATNR text * -->PT_MARC text *----------------------------------------------------------------------* FORM get_marc USING pv_month TYPE spmon pt_werks TYPE range_t_werks_d pt_matnr TYPE ranges_matnr CHANGING pt_marc TYPE ztt_mm_marc. DATA : lv_lfgja LIKE mard-lfgja, lv_lfmon LIKE mard-lfmon. lv_lfgja = pv_month+0(4). lv_lfmon = pv_month+4(2). SELECT a~werks a~lfgja a~lfmon a~matnr a~trame APPENDING CORRESPONDING FIELDS OF TABLE pt_marc FROM marc AS a WHERE a~matnr IN pt_matnr AND a~werks IN pt_werks AND a~lfgja = ( SELECT MAX( lfgja ) FROM marc WHERE matnr = a~matnr AND werks = a~werks AND ( lfgja LT lv_lfgja OR ( lfgja EQ lv_lfgja AND lfmon LE lv_lfmon ) ) ) AND a~lfmon = ( SELECT MAX( lfmon ) FROM marc WHERE matnr = a~matnr AND werks = a~werks AND ( ( lfgja EQ a~lfgja AND lfgja LT lv_lfgja ) OR ( lfgja EQ lv_lfgja AND lfmon LE lv_lfmon ) ) ) AND a~trame NE 0 %_HINTS ORACLE '&MAX_BLOCKING_FACTOR 20&'. SELECT a~werks a~lfgja a~lfmon a~matnr a~trame APPENDING CORRESPONDING FIELDS OF TABLE pt_marc FROM march AS a WHERE a~matnr IN pt_matnr AND a~werks IN pt_werks AND a~lfgja = ( SELECT MIN( lfgja ) FROM march WHERE matnr = a~matnr AND werks = a~werks AND ( lfgja GT lv_lfgja OR ( lfgja EQ lv_lfgja AND lfmon GE lv_lfmon ) ) ) AND a~lfmon = ( SELECT MIN( lfmon ) FROM march WHERE matnr = a~matnr AND werks = a~werks AND ( ( lfgja EQ a~lfgja AND lfgja GT lv_lfgja ) OR ( lfgja EQ lv_lfgja AND lfmon GE lv_lfmon ) ) ) AND a~trame NE 0 %_HINTS ORACLE '&MAX_BLOCKING_FACTOR 20&'. ENDFORM. "get_marc *&---------------------------------------------------------------------* *& Form get_mchb *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * -->PV_MONTH text * -->PT_WERKS text * -->PT_MATNR text * -->PT_LGORT text * -->PT_MCHB text *----------------------------------------------------------------------* FORM get_mchb USING pv_month TYPE spmon pt_werks TYPE range_t_werks_d pt_matnr TYPE ranges_matnr pt_lgort TYPE range_t_lgort_d CHANGING pt_mchb TYPE ztt_mm_mchb. DATA : lv_lfgja LIKE mard-lfgja, lv_lfmon LIKE mard-lfmon. lv_lfgja = pv_month+0(4). lv_lfmon = pv_month+4(2). SELECT a~werks a~matnr a~lgort a~charg a~lfgja a~lfmon a~clabs a~cinsm a~cspem a~ersda a~laeda APPENDING CORRESPONDING FIELDS OF TABLE pt_mchb FROM mchb AS a WHERE a~matnr IN pt_matnr AND a~werks IN pt_werks AND a~lgort IN pt_lgort AND a~lfgja = ( SELECT MAX( lfgja ) FROM mchb WHERE matnr = a~matnr AND werks = a~werks AND lgort = a~lgort AND charg = a~charg AND ( lfgja LE lv_lfgja OR ( lfgja EQ lv_lfgja AND lfmon LE lv_lfmon ) ) ) AND a~lfmon = ( SELECT MAX( lfmon ) FROM mchb WHERE matnr = a~matnr AND werks = a~werks AND lgort = a~lgort AND charg = a~charg AND ( ( lfgja EQ a~lfgja AND lfgja LT lv_lfgja ) OR ( lfgja EQ lv_lfgja AND lfmon LE lv_lfmon ) ) ) AND ( a~clabs NE 0 OR a~cinsm NE 0 OR a~cspem NE 0 ) %_HINTS ORACLE '&MAX_BLOCKING_FACTOR 20&'. SELECT a~werks a~matnr a~lgort a~charg a~lfgja a~lfmon a~clabs a~cinsm a~cspem APPENDING CORRESPONDING FIELDS OF TABLE pt_mchb FROM mchbh AS a WHERE a~matnr IN pt_matnr AND a~werks IN pt_werks AND a~lgort IN pt_lgort AND lfgja = ( SELECT MIN( lfgja ) FROM mchbh WHERE matnr = a~matnr AND werks = a~werks AND lgort = a~lgort AND charg = a~charg AND ( lfgja GT lv_lfgja OR ( lfgja EQ lv_lfgja AND lfmon GE lv_lfmon ) ) ) AND lfmon = ( SELECT MIN( lfmon ) FROM mchbh WHERE matnr = a~matnr AND werks = a~werks AND lgort = a~lgort AND charg = a~charg AND ( ( lfgja EQ a~lfgja AND lfgja GT lv_lfgja ) OR ( lfgja EQ lv_lfgja AND lfmon GE lv_lfmon ) ) ) AND ( a~clabs NE 0 OR a~cinsm NE 0 OR a~cspem NE 0 ) %_HINTS ORACLE '&MAX_BLOCKING_FACTOR 20&'. ENDFORM. "get_mchb *&---------------------------------------------------------------------* *& Form get_mkol *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * -->PV_MONTH text * -->PT_WERKS text * -->PT_MATNR text * -->PT_LGORT text * -->PT_MKOL text *----------------------------------------------------------------------* FORM get_mkol USING pv_month TYPE spmon pt_werks TYPE range_t_werks_d pt_matnr TYPE ranges_matnr pt_lgort TYPE range_t_lgort_d CHANGING pt_mkol TYPE ztt_mm_mkol. DATA : lv_lfgja LIKE mard-lfgja, lv_lfmon LIKE mard-lfmon. lv_lfgja = pv_month+0(4). lv_lfmon = pv_month+4(2). SELECT a~werks a~matnr a~lgort a~charg a~sobkz a~lifnr a~lfgja a~lfmon a~slabs a~sinsm a~sspem APPENDING CORRESPONDING FIELDS OF TABLE pt_mkol FROM mkol AS a WHERE a~matnr IN pt_matnr AND a~werks IN pt_werks AND a~lgort IN pt_lgort AND a~lfgja = ( SELECT MAX( lfgja ) FROM mkol WHERE matnr = a~matnr AND werks = a~werks AND lgort = a~lgort AND charg = a~charg AND sobkz = a~sobkz AND lifnr = a~lifnr AND ( lfgja LE lv_lfgja OR ( lfgja EQ lv_lfgja AND lfmon LE lv_lfmon ) ) ) AND a~lfmon = ( SELECT MAX( lfmon ) FROM mkol WHERE matnr = a~matnr AND werks = a~werks AND lgort = a~lgort AND charg = a~charg AND sobkz = a~sobkz AND lifnr = a~lifnr AND ( ( lfgja EQ a~lfgja AND lfgja LT lv_lfgja ) OR ( lfgja EQ lv_lfgja AND lfmon LE lv_lfmon ) ) ) AND ( a~slabs NE 0 OR a~sinsm NE 0 OR a~sspem NE 0 ) %_HINTS ORACLE '&MAX_BLOCKING_FACTOR 20&'. SELECT a~werks a~matnr a~lgort a~charg a~sobkz a~lifnr a~lfgja a~lfmon a~slabs a~sinsm a~sspem APPENDING CORRESPONDING FIELDS OF TABLE pt_mkol FROM mkolh AS a WHERE a~matnr IN pt_matnr AND a~werks IN pt_werks AND a~lgort IN pt_lgort AND lfgja = ( SELECT MIN( lfgja ) FROM mkolh WHERE matnr = a~matnr AND werks = a~werks AND lgort = a~lgort AND charg = a~charg AND sobkz = a~sobkz AND lifnr = a~lifnr AND ( lfgja GT lv_lfgja OR ( lfgja EQ lv_lfgja AND lfmon GE lv_lfmon ) ) ) AND lfmon = ( SELECT MIN( lfmon ) FROM mkolh WHERE matnr = a~matnr AND werks = a~werks AND lgort = a~lgort AND charg = a~charg AND sobkz = a~sobkz AND lifnr = a~lifnr AND ( ( lfgja EQ a~lfgja AND lfgja GT lv_lfgja ) OR ( lfgja EQ lv_lfgja AND lfmon GE lv_lfmon ) ) ) AND ( a~slabs NE 0 OR a~sinsm NE 0 OR a~sspem NE 0 ) %_HINTS ORACLE '&MAX_BLOCKING_FACTOR 20&'. ENDFORM. "get_mkol
'SAP > ABAP' 카테고리의 다른 글
SAPscript Control Tables (0) | 2014.10.24 |
---|---|
Convert Internal date to External date ( date, month ) (0) | 2014.09.24 |
Get Structure/Table sub-components (0) | 2014.09.12 |
Excel DATEVALUE to DATE conversion (0) | 2014.08.29 |
excel download ( OLE based ) (0) | 2014.02.18 |