2006 Dec 26 6:51 AM
Just need your help in solving one issue. In the below code one query which is highlighted
Select statement not working means cursor directly goes to the endselect .means these two statements not executed.
CLASS cl_abap_container_utilities DEFINITION LOAD.
CALL METHOD cl_abap_container_utilities=>read_container_c
I am attaching that code with this mail. Please do the needful help.
&----
*& Report ZEOU_RG1 *
*& *
&----
*& *
*& *
&----
REPORT zeou_rg1 LINE-SIZE 400.
*
************************************************************************
Purpose : RG1 Report driver
Remarks :
************************************************************************
constants
INCLUDE j_2icons.
type declerations
INCLUDE j_2isdef.
table definitions and internal tables
INCLUDE j_2iddef.
*
INCLUDE <icon>.
*
DATA: $plant TYPE bp_addr_typ,
$lincnt LIKE sy-linct,
m_date LIKE j_1ipart2-budat,
m_chapid LIKE j_1iexcdtl-chapid,
m_matform LIKE j_1irg1-matform,
m_bedrate LIKE j_1irg1-bedrate,
tot_op_bal LIKE j_1irg1-menge,
tot_qty_mnfr LIKE j_1irg1-menge,
tot_total_qty_mnfr LIKE j_1irg1-menge,
tot_remv_home LIKE j_1irg1-menge,
tot_remv_hval LIKE j_1irg1-exbas,
tot_remv_expr LIKE j_1irg1-menge,
tot_remv_eval LIKE j_1irg1-exbas,
tot_remv_expb LIKE j_1irg1-menge,
tot_remv_othr LIKE j_1irg1-menge,
tot_remv_opur LIKE j_1irg1-menge,
tot_duty_amt LIKE j_1irg1-exbed,
tot_cb_fr LIKE j_1irg1-exbed,
tot_cb_br LIKE j_1irg1-exbed.
*
DATA: t_rg1_cons TYPE rg1_typ OCCURS 0 WITH HEADER LINE.
FIELD-SYMBOLS: <x_extrctdata> TYPE c,
<x_rg1> TYPE rg1_typ,
<x_part1typ> TYPE part1_typ.
DATA : it_j_1iexchdr TYPE j_1iexchdr OCCURS 0 WITH HEADER LINE,
wa_j_1iexchdr TYPE j_1iexchdr,
it_j_1iexcdtl TYPE j_1iexcdtl OCCURS 0 WITH HEADER LINE,
wa_j_1iexcdtl TYPE j_1iexcdtl.
selection screen
PARAMETERS: p_exgrp LIKE j_1iexchdr-exgrp OBLIGATORY MEMORY ID j2i,
p_stdate LIKE sy-datum OBLIGATORY,
p_endate LIKE sy-datum OBLIGATORY.
*SELECTION-SCREEN SKIP 1.
*SELECTION-SCREEN BEGIN OF BLOCK 4 WITH FRAME TITLE TEXT-001.
*SELECTION-SCREEN BEGIN OF LINE.
*SELECTION-SCREEN POSITION 01.
*PARAMETERS: P_INDI RADIOBUTTON GROUP 57F4 DEFAULT 'X'.
*SELECTION-SCREEN COMMENT (25) TEXT-002.
*SELECTION-SCREEN END OF LINE.
*
*SELECTION-SCREEN BEGIN OF LINE.
*SELECTION-SCREEN POSITION 01.
*PARAMETERS: P_CONS RADIOBUTTON GROUP 57F4.
*SELECTION-SCREEN COMMENT (25) TEXT-003.
*SELECTION-SCREEN END OF LINE.
*SELECTION-SCREEN END OF BLOCK 4.
INITIALIZATION.
AT SELECTION-SCREEN.
SELECT SINGLE *
FROM j_1iexgrps
WHERE j_1iexcgrp = p_exgrp.
IF sy-subrc NE 0.
MESSAGE e399(8i) WITH p_exgrp.
ENDIF.
*check company code
SELECT SINGLE *
FROM t001k
WHERE bwkey = j_1iexgrps-j_1iwerks.
IF sy-subrc NE 0.
MESSAGE e518(8i) WITH 'the' 'plant' j_1iexgrps-j_1iwerks.
ENDIF.
<b>START-OF-SELECTION.
CLEAR: j_1irg1, j_2icomp.
retrieve layout name and details
SELECT SINGLE *
FROM J_2ILAYCTR
WHERE BUKRS = T001K-BUKRS
AND REGISTER = C_RG1
AND LAYOUTNR = 1.
IF SY-SUBRC NE 0.
MESSAGE E635(8I) WITH T001K-BUKRS C_RG1.
ENDIF.
SET COUNTRY 'IN'.
REFRESH t_reciepts.
report driver logic
SELECT *
FROM j_2iextrct
WHERE exgrp = p_exgrp
AND budat >= p_stdate
AND budat <= p_endate
AND register = c_rg1
ORDER BY budat keyid.
assign J_2IEXTRCT-EXTRCTDATA to <x_extrctdata> casting.
assign T_RG1 to <x_rg1> casting.
<x_rg1> = <x_extrctdata>.
CLASS cl_abap_container_utilities DEFINITION LOAD.
CALL METHOD cl_abap_container_utilities=>read_container_c
EXPORTING
im_container = j_2iextrct-extrctdata
IMPORTING
ex_value = t_rg1
EXCEPTIONS
illegal_parameter_type = 1
OTHERS = 2.
MOVE J_2IEXTRCT-EXTRCTDATA TO T_RG1.
APPEND t_rg1.
ENDSELECT.
DESCRIBE TABLE t_rg1 LINES $lincnt.
IF $lincnt = 0.
MESSAGE e548(8i) WITH p_stdate p_endate.
ENDIF.</b>
PERFORM PLANT_AND_EXCISE_DTLS USING P_WERKS.
PERFORM plant_and_excise_dtls USING j_1iexgrps-j_1iwerks.
MOVE : 'ZJ_2I_RG1' TO j_2ilayctr-layoutname.
SORT t_rg1 BY chapid matnr cpudt .
open form
PERFORM open_form USING j_2ilayctr-layoutname j_2ilayctr-noofcopies "J_2ILAYCTR-LAYOUTNAME
j_2ilayctr-outdevice true.
process extract data and write
IF P_INDI = 'X'.
PERFORM get_data_and_write.
ELSEIF P_CONS = 'X'.
PERFORM RG1_PRINT_CONS.
PERFORM GET_DATA_AND_WRITE_CONS.
ENDIF.
close form
PERFORM close_form.
************************************************************************
F O R M S
************************************************************************
INCLUDE j_2ilayo.
&----
*& Form GET_DATA_AND_WRITE
&----
Purpose : Logic to print RG1 report
----
FORM get_data_and_write.
*
DATA: save_matnr LIKE mara-matnr.
CLEAR: j_1irg1, j_2icomp, save_matnr.
SELECT * FROM j_1iexchdr INTO TABLE it_j_1iexchdr
WHERE exgrp = p_exgrp
AND budat >= p_stdate
AND budat <= p_endate.
SORT it_j_1iexchdr BY cpudt docno.
LOOP AT it_j_1iexchdr.
SELECT * FROM j_1iexcdtl INTO wa_j_1iexcdtl
WHERE docno = it_j_1iexchdr-docno.
APPEND wa_j_1iexcdtl TO it_j_1iexcdtl.
ENDSELECT.
ENDLOOP.
clear wa_j_1iexcdtl.
SORT it_j_1iexcdtl BY chapid matnr cpudt docno.
LOOP AT t_rg1.
CLEAR: j_1irg1, j_2icomp.
assign header fields
j_2icomp-stdate = p_stdate.
j_2icomp-endate = p_endate.
IF save_matnr NE t_rg1-matnr.
fill header line with matnr, description, chapterid and unit
j_1irg1-chapid = t_rg1-chapid.
mara-matnr = t_rg1-matnr.
marav-maktx = t_rg1-maktx.
mara-meins = t_rg1-meins.
save_matnr = t_rg1-matnr.
IF sy-tabix NE 1.
j_2icomp-new_page = true.
ELSE.
j_2icomp-new_page = false.
ENDIF.
ELSE.
j_2icomp-new_page = false.
ENDIF.
PERFORM write_form USING element-spac function-set
typ-body window-main .
determine line to display viz. manufacture entry/removal entry
IF t_rg1-matform = c_packed.
j_2icomp-rg1_p_l = c_packed.
ELSEIF t_rg1-matform = c_loose.
j_2icomp-rg1_p_l = c_loose.
ENDIF.
j_1irg1-cpudt = t_rg1-cpudt.
j_2icomp-op_qty = t_rg1-op_bal.
j_2icomp-mf_qty = t_rg1-qty_mfr.
j_2icomp-to_qty = t_rg1-total.
j_2icomp-cl_fin = t_rg1-cl_bal_fn.
j_2icomp-cl_bon = t_rg1-cl_bal_bn.
j_2icomp-remarks = t_rg1-remarks.
j_2icomp-h_menge = t_rg1-h_menge.
j_2icomp-h_value = t_rg1-h_value.
j_2icomp-e_menge = t_rg1-e_menge.
j_2icomp-e_value = t_rg1-e_value.
j_2icomp-e_menge_bn = t_rg1-e_menge_bond.
j_2icomp-o_menge = t_rg1-o_menge.
j_2icomp-o_purpose = t_rg1-o_purpose.
j_2icomp-o_pur_meng = t_rg1-o_pur_menge.
j_1irg1-bedrate = t_rg1-bedrate.
j_1irg1-exbed = t_rg1-bedamt.
j_2icomp-cl_fin = t_rg1-cl_bal_fn.
j_2icomp-cl_bon = t_rg1-cl_bal_bn.
j_2icomp-remarks = t_rg1-remarks.
READ TABLE it_j_1iexcdtl WITH KEY cpudt = t_rg1-cpudt
chapid = t_rg1-chapid
matnr = t_rg1-matnr.
*
IF sy-subrc = 0.
get duties for issues only.
IF t_rg1-rcptissrsn = 'IPD'
OR t_rg1-rcptissrsn = 'IWD'
OR t_rg1-rcptissrsn = 'IDH'
OR t_rg1-rcptissrsn = 'IDE'
OR t_rg1-rcptissrsn = 'IWE'
OR t_rg1-rcptissrsn = 'IWT'
OR t_rg1-rcptissrsn = 'IWO'.
READ TABLE it_j_1iexchdr WITH KEY exnum = t_rg1-rdoc1
trntyp = 'DLFC'
cpudt = t_rg1-cpudt.
READ TABLE it_j_1iexcdtl WITH KEY docno = it_j_1iexchdr-docno
cpudt = it_j_1iexchdr-cpudt
trntyp = 'DLFC'
matnr = t_rg1-matnr.
docyr = it_j_1iexchdr-docyr
IF IT_j_1iexchdr-expind <> 'B'
and it_j_1iexchdr-expind <> 'U'
and it_j_1iexchdr-expind <> 'D'
and it_j_1iexchdr-expind <> 'N'
AND T_RG1-h_menge > 0.
and it_j_1iexchdr-expind IS INITIAL.
IF it_j_1iexchdr-censtat = 'P'.
wa_j_1iexcdtl-ecs = it_j_1iexcdtl-ecs.
ENDIF.
IF it_j_1iexchdr-censtat = 'C'.
wa_j_1iexchdr-exbed = it_j_1iexchdr-exbed.
wa_j_1iexchdr-ecs = it_j_1iexchdr-ecs.
wa_j_1iexchdr-censtat = it_j_1iexchdr-censtat.
wa_j_1iexchdr-cpudt = it_j_1iexchdr-cpudt.
wa_j_1iexcdtl-rgplaser = it_j_1iexcdtl-rgplaser.
wa_j_1iexcdtl-rg23aser = it_j_1iexcdtl-rg23aser.
ENDIF.
ENDIF.
endif.
ENDIF.
PERFORM write_form USING element-d function-append
typ-body window-main .
CLEAR : wa_j_1iexchdr, wa_j_1iexcdtl.
ENDLOOP.
ENDFORM. " GET_DATA_AND_WRITE
&----
*& Form GET_DATA_AND_WRITE_CONS
&----
text *
----
--> p1 text
<-- p2 text
----
FORM get_data_and_write_cons.
DATA: save_chapid LIKE j_1iexcdtl-chapid.
CLEAR: j_1irg1, j_2icomp, save_chapid.
*
LOOP AT t_rg1_cons.
CLEAR: j_1irg1, j_2icomp.
assign header fields
j_2icomp-stdate = p_stdate.
j_2icomp-endate = p_endate.
IF save_chapid NE t_rg1_cons-chapid.
fill header line with chapterid
j_1irg1-chapid = t_rg1_cons-chapid.
save_chapid = t_rg1_cons-chapid.
IF sy-tabix NE 1.
j_2icomp-new_page = true.
ELSE.
j_2icomp-new_page = false.
ENDIF.
ELSE.
j_2icomp-new_page = false.
ENDIF.
PERFORM write_form USING element-spac function-set
typ-body window-main .
determine line to display viz. manufacture entry/removal entry
IF t_rg1_cons-matform = c_packed.
j_2icomp-rg1_p_l = c_packed.
ELSEIF t_rg1_cons-matform = c_loose.
j_2icomp-rg1_p_l = c_loose.
ENDIF.
j_1irg1-cpudt = t_rg1_cons-cpudt.
j_2icomp-op_qty = t_rg1_cons-op_bal.
j_2icomp-mf_qty = t_rg1_cons-qty_mfr.
j_2icomp-to_qty = t_rg1_cons-total.
j_2icomp-cl_fin = t_rg1_cons-cl_bal_fn.
j_2icomp-cl_bon = t_rg1_cons-cl_bal_bn.
j_2icomp-remarks = t_rg1_cons-remarks.
j_2icomp-h_menge = t_rg1_cons-h_menge.
j_2icomp-h_value = t_rg1_cons-h_value.
j_2icomp-e_menge = t_rg1_cons-e_menge.
j_2icomp-e_value = t_rg1_cons-e_value.
j_2icomp-e_menge_bn = t_rg1_cons-e_menge_bond.
j_2icomp-o_menge = t_rg1_cons-o_menge.
j_2icomp-o_purpose = t_rg1_cons-o_purpose.
j_2icomp-o_pur_meng = t_rg1_cons-o_pur_menge.
j_1irg1-bedrate = t_rg1_cons-bedrate.
j_1irg1-exbed = t_rg1_cons-bedamt.
j_2icomp-cl_fin = t_rg1_cons-cl_bal_fn.
j_2icomp-cl_bon = t_rg1_cons-cl_bal_bn.
j_2icomp-remarks = t_rg1_cons-remarks.
PERFORM write_form USING element-d function-append
typ-body window-main .
*for grand totals
tot_remv_hval = tot_remv_hval + t_rg1_cons-h_value.
tot_remv_eval = tot_remv_eval + t_rg1_cons-e_value.
tot_duty_amt = tot_duty_amt + t_rg1_cons-bedamt.
ENDLOOP.
*for grand totals
j_2icomp-amount1 = tot_remv_hval.
j_2icomp-amount2 = tot_remv_eval.
j_2icomp-amount3 = tot_duty_amt.
PERFORM write_form USING element-t function-append
typ-body window-footer.
ENDFORM. " GET_DATA_AND_WRITE_CONS
&----
*& Form RG1_PRINT_CONS
&----
text *
----
--> p1 text
<-- p2 text
----
FORM rg1_print_cons.
DATA : first_time VALUE on.
*
SORT t_rg1 BY chapid cpudt.
LOOP AT t_rg1.
IF first_time = on.
m_chapid = t_rg1-chapid.
m_date = t_rg1-cpudt.
m_matform = t_rg1-matform.
m_bedrate = t_rg1-bedrate.
first_time = off.
ENDIF.
IF m_chapid <> t_rg1-chapid.
PERFORM chapid_break.
ELSEIF m_date <> t_rg1-cpudt.
PERFORM date_break.
ENDIF.
Accumulate totals
tot_op_bal = tot_op_bal + t_rg1-op_bal.
tot_qty_mnfr = tot_qty_mnfr + t_rg1-qty_mfr.
tot_total_qty_mnfr = tot_total_qty_mnfr + t_rg1-total.
tot_remv_home = tot_remv_home + t_rg1-h_menge.
tot_remv_hval = tot_remv_hval + t_rg1-h_value.
tot_remv_expr = tot_remv_expr + t_rg1-e_menge.
tot_remv_eval = tot_remv_eval + t_rg1-e_value.
tot_remv_expb = tot_remv_expb + t_rg1-e_menge_bond.
tot_remv_othr = tot_remv_othr + t_rg1-o_menge.
tot_remv_opur = tot_remv_opur + t_rg1-o_pur_menge.
tot_duty_amt = tot_duty_amt + t_rg1-bedamt.
tot_cb_fr = tot_cb_fr + t_rg1-cl_bal_fn.
tot_cb_br = tot_cb_br + t_rg1-cl_bal_bn.
ENDLOOP.
PERFORM chapid_break.
ENDFORM. " RG1_PRINT_CONS
&----
*& Form DATE_BREAK
&----
text *
----
--> p1 text
<-- p2 text
----
FORM date_break.
CLEAR t_rg1_cons.
t_rg1_cons-chapid = m_chapid.
t_rg1_cons-cpudt = m_date.
t_rg1_cons-op_bal = tot_op_bal.
t_rg1_cons-qty_mfr = tot_qty_mnfr.
t_rg1_cons-total = tot_total_qty_mnfr.
t_rg1_cons-h_menge = tot_remv_home.
t_rg1_cons-h_value = tot_remv_hval.
t_rg1_cons-e_menge = tot_remv_expr.
t_rg1_cons-e_value = tot_remv_eval.
t_rg1_cons-e_menge_bond = tot_remv_expb.
t_rg1_cons-o_menge = tot_remv_othr.
t_rg1_cons-o_pur_menge = tot_remv_opur.
t_rg1_cons-bedamt = tot_duty_amt.
t_rg1_cons-cl_bal_fn = tot_cb_fr.
t_rg1_cons-cl_bal_bn = tot_cb_br.
t_rg1_cons-matform = m_matform.
t_rg1_cons-bedrate = m_bedrate.
APPEND t_rg1_cons.
tot_op_bal = 0.
tot_qty_mnfr = 0.
tot_total_qty_mnfr = 0.
tot_remv_home = 0.
tot_remv_hval = 0.
tot_remv_expr = 0.
tot_remv_eval = 0.
tot_remv_expb = 0.
tot_remv_othr = 0.
tot_remv_opur = 0.
tot_duty_amt = 0.
tot_cb_fr = 0.
tot_cb_br = 0.
m_date = t_rg1-cpudt.
m_matform = t_rg1-matform.
m_bedrate = t_rg1-bedrate.
ENDFORM. " DATE_BREAK
&----
*& Form CHAPID_BREAK
&----
text
**----
*
--> p1 text
<-- p2 text
----
FORM chapid_break.
PERFORM date_break.
m_chapid = t_rg1-chapid.
ENDFORM. " CHAPID_BREAK
.
2006 Dec 26 6:59 AM
2006 Dec 26 7:02 AM
it seems databsae is not having any data as per ur where condition in select query..
do onething go to se11 and the concerned table there and there give ur selection criteria as in the select query and see if u get any output there ..
and then change ur selection conition accordingly in the program..
reward if helpfull
amit
2006 Dec 26 7:03 AM
hi rakesh,
in your first select single * statement you have given WHERE BUKRS = T001K-BUKRS..but at the point of execution, what will be the value stored in t001k-bukrs...i doubt it will be initial....so, store bukrs in a variable or hardcode it.....
in the second select, you hve not given any target work area for the into class...that's y your subrc is 4...specify a target area, where you want the data to be stored...
2006 Dec 26 7:14 AM
If i give target area then what is use of this below code .
and plz tell me one thing how i give target work area for the into class.
CLASS cl_abap_container_utilities DEFINITION LOAD.
CALL METHOD cl_abap_container_utilities=>read_container_c
EXPORTING
im_container = j_2iextrct-extrctdata
IMPORTING
ex_value = t_rg1
EXCEPTIONS
illegal_parameter_type = 1
OTHERS = 2.
2006 Dec 26 7:40 AM
Hi satish ,
If i give target area then what is use class and function module .
and plz tell me one thing how i give target work area for the into class.
2006 Dec 26 8:45 AM
hi,
I check the table select criteria for select query if right. But the function module is not working .give me some suggestion what I can do.
2006 Dec 26 9:27 AM
I dont know why want use this FM, because this FM is expecting a Container Name ( this would be the container which will be used to display lets say an ALV GRID or an ALV TREE ) etc. But the field EXTRCTDATA doesnt contain an CONTAINER name instead it has other data related data extraction.
This FM will never work if you dont pass the container name.
2006 Dec 26 7:07 AM
cross check tables entries for <b>j_2iextrct</b> in se16.
Regards
Prabhu