2009 Jan 22 4:01 AM
Hi,
I want Product hierarchy Description in my report with Number of the level in the product hierarchy like..
00001...............................1..........................Tools
0000100001......................2..........................Electrical parts
000010000100000001 ........3...........................Screwdrivers
with all three levels....
I m picking PRODH (Product hierarchy) from s501 table with other records...with the ref. of PRODH, i want Product hierarchy Description, with all 3 levels....
When i join both tables (s501 & V_T179), it gives syntax error that it is not abap dictionary table as a table, projection view or database view...
then how can i pick Product hierarchy Description with 3 levels..
Please let me know...
Thanks..
2009 Jan 22 4:10 AM
Hi
You need to move the PRODH/PRDHA value to another ITAB.
Delete adjacent duplicates from the same.
then loop ITAB split them into 3 levels
WA1-PRODH = WA1-PRODH+0(5).
append WA1 to ITAB1.
WA1-PRODH = WA1-PRODH+0(10).
append WA1 to ITAB1.
WA1-PRODH = WA1-PRODH.
append WA1 to ITAB1.
Regards
Shiva
2009 Jan 22 6:19 AM
Hi,
Product hierarchy Description with all levels is not coming....
I m sending my code..please let me know where is mistake...
code...........
{
REPORT z_fi_gross_margin NO STANDARD PAGE HEADING LINE-SIZE 125 .
TABLES : t179t, t179, tvkbt, mara, vbrp, s501, mbew, t134t, v_t179.
TYPE-POOLS : slis.
DATA : BEGIN OF itab OCCURS 0,
vkbur LIKE s501-vkbur,
matnr LIKE s501-matnr,
prodh LIKE s501-prodh,
ummenge LIKE s501-ummenge,
gumenge LIKE s501-gumenge,
umnetwr LIKE s501-umnetwr,
gunetwr LIKE s501-gunetwr,
sptag LIKE s501-sptag,
peinh LIKE mbew-peinh,
stprs LIKE mbew-stprs,
lplpx LIKE mbew-lplpx,
vtext LIKE t179t-vtext,
vtext1 LIKE t179t-vtext,
vtext2 LIKE t179t-vtext,
stufe LIKE t179-stufe,
mtart LIKE mara-mtart,
bezei LIKE tvkbt-bezei,
net_sqty TYPE p DECIMALS 2,
s_amt TYPE p DECIMALS 2,
mtbez LIKE t134t-mtbez,
j_1ichid LIKE j_1imtchid-j_1ichid,
rate LIKE j_1iexctax-rate,
excise TYPE p DECIMALS 2,
l_excise TYPE p DECIMALS 2,
s_unit TYPE p DECIMALS 2,
m_unit TYPE p DECIMALS 2,
t_mcost TYPE p DECIMALS 2,
m_cost% TYPE p DECIMALS 2,
g_margin TYPE p DECIMALS 2,
g_marg% TYPE p DECIMALS 2,
END OF itab.
DATA : BEGIN OF itab1 OCCURS 0,
prodh LIKE s501-prodh,
vtext LIKE t179t-vtext,
vtext1 LIKE t179t-vtext,
vtext2 LIKE t179t-vtext,
stufe LIKE t179-stufe,
END OF itab1.
DATA : v_index TYPE sy-tabix.
DATA : cnt TYPE i.
DATA : itab2 LIKE STANDARD TABLE OF itab1 WITH HEADER LINE.
************************************************************************
DATA : w_container TYPE scrfname VALUE 'CL_GRID',
w_cprog TYPE lvc_s_layo,
g_repid LIKE sy-repid,
w_save TYPE c,
w_exit TYPE c,
cl_grid TYPE REF TO cl_gui_alv_grid,
cl_custom_container TYPE REF TO cl_gui_custom_container,
it_fld_catalog TYPE slis_t_fieldcat_alv,
wa_fld_catalog TYPE slis_t_fieldcat_alv WITH HEADER LINE ,
layout TYPE slis_layout_alv,
col_pos LIKE sy-cucol ,
alvfc TYPE slis_t_fieldcat_alv.
************************************************************************
SELECTION-SCREEN : BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
SELECT-OPTIONS : vkbur FOR s501-vkbur.
SELECT-OPTIONS : matnr FOR s501-matnr.
SELECT-OPTIONS : sptag FOR s501-sptag.
PARAMETER : mydate LIKE sy-datum.
SELECTION-SCREEN : END OF BLOCK b1.
************************************************************************
PERFORM fill_catalog1 USING:
'SPTAG' 'ITAB' 'DATE',
'VKBUR' 'ITAB' 'Sales Office',
'BEZEI' 'ITAB' 'S.Off. Desc.',
'MATNR' 'ITAB' 'Material',
'PRODH' 'ITAB' 'LEVEL',
'VTEXT' 'ITAB' 'Level I',
'VTEXT1' 'ITAB' 'Level II',
'VTEXT2' 'ITAB' 'Level III',
'MTBEZ' 'ITAB' 'Material Type',
'NET_SQTY' 'ITAB' 'Net Sales Qty.',
'S_AMT' 'ITAB' 'Sales with Ex. Duty',
'EXCISE' 'ITAB' 'Excise Duty',
'RATE' 'ITAB' '% Excise Duty',
'L_EXCISE' 'ITAB' 'Sales less Ex. Duty',
'S_UNIT' 'ITAB' 'Sales / Unit',
'M_UNIT' 'ITAB' 'Mat / Unit',
'T_MCOST' 'ITAB' 'Total Material Cost',
'M_COST%' 'ITAB' '% Material Cost',
'G_MARGIN' 'ITAB' 'Gross Margin',
'G_MARG%' 'ITAB' '% Gross Margin',
'NEW' 'ITAB' 'Month'.
*********************************************************************************************
SELECT DISTINCT a~sptag a~vkbur a~matnr a~prodh a~ummenge a~gumenge a~umnetwr a~gunetwr b~vtext c~mtart d~bezei e~mtbez f~stufe
INTO CORRESPONDING FIELDS OF TABLE itab
FROM s501 AS a
INNER JOIN t179t AS b ON a~prodh = b~prodh
INNER JOIN mara AS c ON a~matnr = c~matnr
INNER JOIN tvkbt AS d ON a~vkbur = d~vkbur
INNER JOIN t134t AS e ON c~mtart = e~mtart
INNER JOIN t179 AS f ON b~prodh = f~prodh
WHERE a~matnr IN matnr
AND a~sptag IN sptag
AND a~vkbur IN vkbur
AND e~spras EQ 'EN'.
IF sy-subrc <> 0.
MESSAGE 'DATA NOT FOUND.' TYPE 'I'(001).
ENDIF.
SORT itab BY matnr.
LOOP AT itab .
cnt = v_index.
SELECT peinh stprs lplpx FROM mbew INTO (itab-peinh, itab-stprs, itab-lplpx) WHERE matnr = itab-matnr.
itab-m_unit = itab-stprs - itab-lplpx / itab-peinh.
v_index = cnt + sy-dbcnt.
MODIFY itab INDEX v_index TRANSPORTING m_unit.
ENDSELECT.
SELECT j_1ichid FROM j_1imtchid INTO itab-j_1ichid WHERE matnr = itab-matnr.
MODIFY itab INDEX sy-tabix TRANSPORTING j_1ichid .
ENDSELECT.
SELECT SINGLE rate FROM j_1iexctax INTO itab-rate WHERE j_1ichid = itab-j_1ichid AND j_1iexcind = '1'. " AND VALIDFROM LE sptag-low AND VALIDTO GE sptag-high.
MODIFY itab INDEX sy-tabix TRANSPORTING rate .
ENDLOOP.
LOOP AT itab .
itab-net_sqty = itab-ummenge - itab-gumenge .
MODIFY itab INDEX sy-tabix TRANSPORTING net_sqty.
itab-s_amt = itab-umnetwr - itab-gunetwr .
MODIFY itab INDEX sy-tabix TRANSPORTING s_amt.
itab-excise = itab-s_amt * itab-rate / 100.
MODIFY itab INDEX sy-tabix TRANSPORTING excise.
itab-l_excise = itab-s_amt - itab-excise.
MODIFY itab INDEX sy-tabix TRANSPORTING l_excise.
itab-s_unit = itab-l_excise / itab-net_sqty.
MODIFY itab INDEX sy-tabix TRANSPORTING s_unit.
itab-t_mcost = itab-m_unit * itab-net_sqty.
MODIFY itab INDEX sy-tabix TRANSPORTING t_mcost.
itab-m_cost% = itab-t_mcost / itab-s_amt * 100.
MODIFY itab INDEX sy-tabix TRANSPORTING m_cost%.
itab-g_margin = itab-l_excise - itab-t_mcost.
MODIFY itab INDEX sy-tabix TRANSPORTING g_margin.
itab-g_marg% = itab-g_margin / itab-s_amt * 100.
MODIFY itab INDEX sy-tabix TRANSPORTING g_marg%.
ENDLOOP.
LOOP AT itab1.
itab1-vtext = itab1-prodh+0(5).
APPEND itab1 TO itab2.
itab1-vtext1 = itab1-prodh+0(10).
APPEND itab1 TO itab2.
itab1-vtext2 = itab1-prodh.
APPEND itab1 TO itab2.
ENDLOOP.
************************************************************************
layout-zebra = 'X' .
layout-colwidth_optimize(1) = 'X'.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = 'Z_FI_GROSS_MARGIN'
is_layout = layout
it_fieldcat = it_fld_catalog
i_default = 'X'
i_save = 'A'
TABLES
t_outtab = itab
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
&----
*& Form FILL_CATALOG1
&----
text
----
-->P_FIELDNAME text
-->P_REF_TABLE text
-->P_SCRTEXT text
----
FORM fill_catalog1 USING p_fieldname TYPE any
p_ref_table TYPE any
p_scrtext TYPE any.
CLEAR : wa_fld_catalog.
wa_fld_catalog-fieldname = p_fieldname.
wa_fld_catalog-tabname = p_ref_table.
wa_fld_catalog-seltext_s = p_scrtext.
wa_fld_catalog-seltext_m = p_scrtext.
wa_fld_catalog-seltext_l = p_scrtext.
wa_fld_catalog-outputlen = 15.
APPEND wa_fld_catalog TO it_fld_catalog.
ENDFORM. " fill_catalog1
}
Thanks
2009 Jan 22 4:30 AM
Hi,
May be you can get the product hierarchy description from T179T table .
Regards,
Phani,
2009 Jan 22 6:36 AM
Use the FM RV_PRODUKTHIERARCHIE_PRED_GET
Pass the required language in SPRAS and pass the Product hierarchy in the field NODE
Regards,
Abhishek Jolly
2009 Jan 22 6:58 AM
Tell me how can i use this FM....
Please provide code for it....
2009 Jan 22 7:39 AM
CALL FUNCTION 'RV_PRODUKTHIERARCHIE_PRED_GET'
EXPORTING
spras = wf_sys_lang
node = wf_prodh
TABLES
disp_t179 = tb_prdha
EXCEPTIONS
node_does_not_exist = 1
OTHERS = 2.
where wf_sys_lang contains value like 'E'
and wf_prodh contains value like '0016301057022021'
2023 Feb 16 8:46 PM