Report/SIE/chn_sd_sdi_open_qty. *&---------------------------------------------------------------------* * & Macro Declaration * *&---------------------------------------------------------------------* Define set_alv_fieldcat. Clear ls_fieldcat. LS_FIELDCAT-FIELDNAME = & 1. "field name The LS_FIELDCAT-TABNAME = & 2. "reference table name The LS_FIELDCAT-COL_POS = & 3. "column position LS_FIELDCAT-OUTPUTLEN = & 4. "output Length The LS_FIELDCAT-SELTEXT_L = & 5. "select text long length LS_FIELDCAT-DDICTXT = 'L'. "using select text type Append ls_fieldcat to it_fieldcat. End-of-definition. Tables: vbak, vbap, vbfa. Type-pools slis. * ALM used fieldcatelog internal table Data: it_fieldcat type slis_t_fieldcat_alv. * Structure and internal table for sales open Qty Data: Begin of r_sq, Vbeln like VBAP-VBELN, Posnr like VBAP-POSNR, Sq (20 ), GQ (20 ), OQ (20 ), End of r_sq, It_sq like table of r_sq. * Structure and table for billing open Qty Data begin of r_bq. Data vbeln like VBAP-VBELN. Data posnr like VBAP-POSNR. Include structure fplt. Data end of r_bq. Data it_bq like table of r_bq. * Selection screen Selection-screen begin of block B1 The TEXT-B01 with frame title. Selection-screen begin of line. Parameter rad1 radiobutton group R1 user-command F1. Selection-screen Comment 3 (20) TEXT-R01 for field rad1. Parameter rad2 radiobutton group R1. Selection-screen comment 40 (20) TEXT-R02 for field rad2. Selection-screen end of line. Selection-screen end of block B1. Select-options: S_vkorg for VBAK-VKORG, S_vtweg for VBAK-VTWEG, S_spart for VBAK-SPART, S_kunnr for VBAK-KUNNR, S_erdat for VBAK-ERDAT, S_auart for VBAK-AUART, S_pstyv for VBAP-PSTYV, S_abgru for VBAP-ABGRU, S_wbs for VBAP-PS_PSP_PNR, S_matnr for VBAP-MATNR, S_vbelv for VBFA-VBELV, S_vbtyp for VBFA-VBTYP_N. * Initialize program Initialization. Rad1 = 'x '. * Change output according to screen Selection At selection-screen output. Perform modif_screen. * Check authority At selection-screen. Perform auth_check. Start-of-selection. If rad1 is initial. * Get billing Qty Perform get_data_bq. * Show billing Qty Perform output_bq. Else. * Get sales open Qty Perform get_data_sq. * Show sales open Qty Perform output_sq. Endif. *&---------------------------------------------------------------------* * & Form modif_screen *&---------------------------------------------------------------------* * Text *----------------------------------------------------------------------* Form modif_screen. If rad1 is initial. Loop at screen. If screen-name CS 'vbelv' or Screen-name CS 'vbtyp '. Screen-active = 0. Modify screen. Endif. Endloop. Endif. Endform. "modif_screen *&---------------------------------------------------------------------* * & Form auth_check *&---------------------------------------------------------------------* * Text *----------------------------------------------------------------------* Form auth_check. * Check whether the user has the transaction code authorization Authority-check object's _ tcode' Id 'stop' field 'va03 '. If SY-SUBRC <> 0. Message e043 (/SIE/chn_all ). Endif. Endform. "auth_check *&---------------------------------------------------------------------* * & Form get_data_bq *&---------------------------------------------------------------------* * Text *----------------------------------------------------------------------* Form get_data_bq. * Join with inner get billing plan * VBAK--VBAP--VBKD--FPLT Select ~ Vbeln B ~ Posnr D ~ Afdat D ~ Tetxt D ~ Mlbez D ~ Fproz D ~ Fakwr D ~ Waers D ~ Faksp D ~ Fareg D ~ Fksaf D ~ Zterm D ~ Fpttp D ~ Fkarv D ~ Kurrf D ~ Mlstn D ~ Fpfix From vbak as a inner join vbap as B on B ~ Vbeln = ~ Vbeln Inner join vbkd as C on C ~ Vbeln = B ~ Vbeln and C ~ Posnr = B ~ Posnr Inner join fplt as D on d ~ Fplnr = C ~ Fplnr Into corresponding fields of table it_bq Where ~ Vkorg in s_vkorg And ~ Vtweg in s_vtweg And ~ Spart in s_spart And ~ Kunnr in s_kunnr And ~ Erdat in s_erdat And ~ Auart in s_auart And B ~ Pstyv in s_pstyv And B ~ Abgru in s_abgru And B ~ Ps_psp_pnr in s_wbs And B ~ Matnr in s_matnr And D ~ Fksaf <> 'C '. If SY-SUBRC <> 0. Message s033 (/SIE/chn_all) With 'no data exists! '. Endif. Endform. "get_data_bq *&---------------------------------------------------------------------* * & Form get_data_sq *&---------------------------------------------------------------------* * Text *----------------------------------------------------------------------* Form get_data_sq. * Local data Data: Begin of lr_sq, Vbeln like VBAP-VBELN, Posnr like VBAP-POSNR, Rfmng like VBFA-RFMNG, Kwmeng like VBAP-KWMENG, OQ like VBAP-KWMENG, Vrkme like a VBAP-VRKME, End of lr_sq. Data: lit_sq like table of lr_sq, Llr_sq like lr_sq. Data: Maid VBFA-RFMNG. * Get sales open Qty * VBAK--VBAP--VBFA Select ~ Vbeln B ~ Posnr B ~ Kwmeng B ~ Vrkme C ~ Rfmng From vbak as a inner join vbap as B on B ~ Vbeln = ~ Vbeln Inner join vbfa as C on C ~ Posnv = B ~ Posnr and C ~ Vbelv = B ~ Vbeln Into corresponding fields of table lit_sq Where ~ Vkorg in s_vkorg And ~ Vtweg in s_vtweg And ~ Spart in s_spart And ~ Kunnr in s_kunnr And ~ Erdat in s_erdat And ~ Auart in s_auart And B ~ Pstyv in s_pstyv And B ~ Abgru in s_abgru And B ~ Ps_psp_pnr in s_wbs And B ~ Matnr in s_matnr And C ~ Vbtyp_n in s_vbtyp. If SY-SUBRC <> 0. Message s033 (/SIE/chn_all) with 'no data exists! '. Endif. * GI qty Summary Sort lit_sq by vbeln posnr. Loop at lit_sq into lr_sq. Llr_sq = lr_sq. L_qty = LLR_SQ-RFMNG + l_qty. At end of posnr. LLR_SQ-OQ = LLR_SQ-KWMENG-l_qty. Write: Rochelle qty to R_SQ-GQ unit LLR_SQ-VRKME, LLR_SQ-KWMENG to R_SQ-SQ unit LLR_SQ-VRKME, LLR_SQ-OQ to R_SQ-OQ unit LLR_SQ-VRKME. R_SQ-VBELN = LLR_SQ-VBELN. R_SQ-POSNR = LLR_SQ-POSNR. Append r_sq to it_sq. Clear: llr_sq, lr_sq, l_qty. Endat. Endloop. Endform. "get_data_sq *&---------------------------------------------------------------------* * & Form output_sq *&---------------------------------------------------------------------* * Text *----------------------------------------------------------------------* Form output_sq. * Define ALV fieldcat Structure Data: ls_fieldcat type slis_fieldcat_alv. * Add data to field catelog Set_alv_fieldcat: 'Vbeln' it _ bq' '1' 12 'TEXT-A01, 'Snr ''it _ bq'' '2' '10' TEXT-A02, 'Sq 'it _ bq' '3' '22' TEXT-A03, 'Gq' it _ bq' '4' 22 'TEXT-A04, 'Oss 'it _ bq' '5' 20' TEXT-A05. * Call function to show result Call function 'reuse _ alv_list_display' Exporting I _callback_program = SY-REPID It_fieldcat = it_fieldcat I _save = 'A' Tables T_outtab = it_sq. Endform. "output_sq *&---------------------------------------------------------------------* * & Form output_bq *&---------------------------------------------------------------------* * Text *----------------------------------------------------------------------* Form output_bq. * Define ALV fieldcat Structure Data: ls_fieldcat type slis_fieldcat_alv. * Add data to field catelog Set_alv_fieldcat: 'Vbeln' it _ sq ''1' 12' TEXT-A01, 'Snr ''it _ sq ''2' '10' TEXT-A02, 'Afdat ''it _ sq ''3' '12' TEXT-B03, 'Textout' it _ sq ''4' '10' TEXT-B04, 'Mlbez' it _ sq ''5' 10' TEXT-B05, 'Fproz' it _ sq ''6' '12' TEXT-B06, 'Fakwr ''it _ sq ''7''' 22 'TEXT-B07, 'Waers' it _ sq ''8' '10' TEXT-B08, 'Faksp ''it _ sq ''9''10' TEXT-B09, 'Fareg 'it _ sq' '10' '10' TEXT-B10, 'Fksaf' it _ sq ''11' '10' TEXT-B11, 'Zla' it _ sq ''12' '10' TEXT-B12, 'Fpttp ''it _ sq ''' 13 ''10' TEXT-B13, 'Fkarv' it _ sq ''14' '10' TEXT-B14, 'Kurrf ''it _ sq ''15''' 20 'TEXT-B15, 'Mlstn ''it _ sq ''16''' 20 'TEXT-B16, 'Fpfix' it _ sq ''17' '10' TEXT-B17. * Call function to show result Call function 'reuse _ alv_list_display' Exporting I _callback_program = SY-REPID It_fieldcat = it_fieldcat I _save = 'A' Tables T_outtab = it_bq. Endform. "output_bq |