Moving the fields to final internal table
hi experts,
i have a single field in an internal table and i want to move it to final internal table.
i tried this code but its not working.
IF NOT it_ymmessr IS INITIAL.
LOOP AT it_ymmessr into it_final..
move it_ymmessr-srvpos to it_final-srvpos.
ENDLOOP.
ENDIF.
there is dat in the it_ymmessr.
i have five to six similar internal tables with 1 to 3 records and i have to move them to final internal table.
regards,
vinay
Hi,
IF NOT it_ymmessr IS INITIAL.
LOOP AT it_ymmessr into it_final..
<b>Have one more firld which is the common field for both the tables into it_ymmessr so that u can fill the record correctly.</b>
READ TABLE it_ymmessr WITH key XXXX = it_final-XXXX.
IF sy-subrc = 0.
it_final-srvpos = it_ymmessr-srvpos.
<b>MODIFY it_final.</b>
ENDIF.
CLAER it_final.
ENDLOOP.
ENDIF.
Similar Messages
-
Problem in moving the data into final internal table
Hello all,
I am stuck in apeculair situation.
I have a internal table having header record and a internal table having its line items.
Header record :: 90006103 A 20080110 ALBERTA 3456
Detail record :: 90006103 D2 2219CR1710441
90006103 D2 2219M11710443
90006103 D2 2219M21710442
90006103 A 20080115 ALBERTA 3456
90006103 D2 2219CR1710441
90006103 D2 2219M11710443
90006103 D2 2219M21710442
I collected the header record in one internal table and another internal table having all the line items.But the problem is when i am moving the values to the final inernal table i am getting the same payment date
20080110 (Date field in first record of header internal table) for all the line items .
But my requirement is that date should be 20080110 for the first 3 line items of first header record and similarly date should be 20080115 for all the line items of the next header record.
Kindly suggest.
Regards,
Arunassumption: some mistake in ur posting that, How belnr and date r same for both header records, so i guess, either one is different.
try with AT NEW - ENDAT.
AT NEW belnr.
here use looping, READing of ur itabs.---> so, u need to build couple of itabs to move forth and back.
ENDAT.
pls. note that, when u use this AT NEW all the CHAR fileds of itab wuld show as STARS **.....so, this is the necessity behind building new itabs.
thanq
Edited by: SAP ABAPer on Dec 30, 2008 6:24 PM -
Difference between the Field Group and Internal Table.
Hi all,
Can anybody tell me the difference between the Field group and Internal table and when they will used?
Thanks,
Sriram.Hi
Internal Tables: They are used to store record type data in tabular form temporarily in ABAP programming. Or we can say, it stores multiple lines of records for temporary use in ABAP programming.
A field group is a user-defined grouping of characteristics and basic key figures from the EC-EIS or EC-BP field catalog.
Use
The field catalog contains the fields that are used in the aspects. As the number of fields grows, the field catalog becomes very large and unclear. To simplify maintenance of the aspects, you can group fields in a field group. You can group the fields as you wish, for example, by subject area or responsibility area. A field may be included in several field groups.
When maintaining the data structure of an aspect, you can select the field group that contains the relevant characteristics and basic key figures. This way you limit the number of fields offered.
Regards
Ashish -
Moving fields to final internal table
hi all,
after i select
elect aufk~aufnr
aufk~objnr
aufk~ktext
vbap~vbeln
vbap~posnr
from
inner join aufk
on vbapaufnr = aufkaufnr
into table t_contracts
where aufk~aufnr in s_proj
and vbap~vbeln in s_vbeln
and vbap~matnr in s_matnr
and vbap~abgru = c_abgru.
sort t_contracts by aufnr vbeln posnr.
i select status from jest like below
if t_contracts[] is not initial.
t_contracts_temp = t_contracts.
delete ADJACENT DUPLICATES FROM t_contracts_temp COMPARING aufnr objnr.
select stat
objnr
from jest
into table it_jest
for all entries in t_contracts_temp
where objnr = t_contracts_temp-objnr
and inact <> c_inact.
Now i want for every objnr the value of jest-stat should move to my final internal table it_contracts.
can you suggest the best way to do it?try:
SELECT aufk~aufnr
aufk~objnr
aufk~ktext
vbap~vbeln
vbap~posnr
jest~stat
FROM ( vbap JOIN aufk
ON vbapaufnr = aufkaufnr )
JOIN jest ON jestobjnr = aufkobjnr
INTO TABLE t_contracts
WHERE aufk~aufnr IN s_proj.
A. -
ALV grid is not displaying few fields of final internal table of type DMBTR
hello frnds,
i am displaying 10 fields in ALV grid using field catalog.
among them five fields are currency fields on which i doing some arithematic operations. but all these fields are not getting displayed in alv grid.
here is my code....
declaring final strucutre to generate report
TYPES:BEGIN OF ty_final,
gjahr TYPE gjahr, " Year
wwert TYPE wwert_d, " Traslation date
bukrs TYPE bukrs, " company code
hkont TYPE hkont, " General ledger account
txt20 TYPE txt20_skat, " Account name
belnr TYPE belnr_d, " Purchase order number
shkzg TYPE shkzg, " Dt/Cr indicator
dmbtr1 TYPE dmbtr, " Ammount in local currency
v_alc TYPE dmbtr, " Ammount in local currency
wrbtr TYPE wrbtr, " Ammount in foreign currency
ebeln TYPE ebeln, " Purchase order number
ebelp TYPE ebelp, " Item number
matnr TYPE matnr, " Material number
menge TYPE menge_d, " Qunatity
meins TYPE meins, " Unit of measure
stprs TYPE stprs, " Std material master
v_iv TYPE dmbtr, " Invoice value
pswsl TYPE pswsl, " Currency
v_erc TYPE dmbtr, " Exchange rate calculated
v_op TYPE dmbtr, " Order price
v_uos TYPE dmbtr, " Unit order to stock
v_io TYPE dmbtr, " Invoice to order
v_uv TYPE dmbtr, " Unit value
v_t TYPE dmbtr, " Total
v_d TYPE dmbtr, " Differecne
netpr TYPE bprei, " Net price in purchasing document
v_total TYPE dmbtr, " Total
v_os TYPE dmbtr, " Order to stock
v_ito TYPE dmbtr, " Invoice to order
saknr TYPE saknr, " G/L account number
END OF ty_final.
FORM move_data.
IF NOT i_bseg[] IS INITIAL.
LOOP AT i_bseg INTO wa_bseg.
wa_final-gjahr = wa_bseg-gjahr.
wa_final-bukrs = wa_bseg-bukrs.
wa_final-hkont = wa_bseg-hkont.
wa_final-belnr = wa_bseg-belnr.
wa_final-shkzg = wa_bseg-shkzg.
wa_final-wrbtr = wa_bseg-wrbtr.
wa_final-ebeln = wa_bseg-ebeln.
wa_final-ebelp = wa_bseg-ebelp.
wa_final-matnr = wa_bseg-matnr.
wa_final-menge = wa_bseg-menge.
wa_final-meins = wa_bseg-meins.
wa_final-pswsl = wa_bseg-pswsl.
wa_final-dmbtr1 = wa_bseg-dmbtr.
wa_final-saknr = wa_bseg-saknr.
wa_final-v_total = wa_bseg-dmbtr.
READ TABLE i_bkpf INTO wa_bkpf WITH KEY bukrs = wa_bseg-bukrs.
IF sy-subrc = 0.
wa_final-wwert = wa_bkpf-wwert.
ENDIF.
CLEAR wa_bkpf.
READ TABLE i_mbew INTO wa_mbew WITH KEY matnr = wa_bseg-matnr.
IF sy-subrc = 0.
wa_final-stprs = wa_mbew-stprs.
ENDIF.
CLEAR wa_mbew.
READ TABLE i_ekpo INTO wa_ekpo WITH KEY ebeln = wa_bseg-ebeln.
IF sy-subrc = 0.
wa_final-netpr = wa_ekpo-netpr.
ENDIF.
CLEAR wa_ekpo.
READ TABLE i_skat INTO wa_skat WITH KEY saknr = wa_bseg-saknr.
IF sy-subrc = 0.
wa_final-txt20 = wa_skat-txt20.
ENDIF.
calculating output values
IF wa_bseg-shkzg = 'H'.
wa_final-v_alc = -1 * wa_bseg-dmbtr.
ELSEIF wa_bseg-shkzg = 'S'.
wa_final-v_alc = 1 * wa_bseg-dmbtr.
ENDIF.
DATA : l_c_v_alc TYPE p DECIMALS 2,
l_c_v_iv TYPE p DECIMALS 2.
l_c_v_alc = wa_final-v_alc.
IF wa_bseg-menge NE 0.
wa_final-v_iv = wa_bseg-dmbtr / wa_bseg-menge.
ENDIF.
IF wa_bseg-dmbtr NE 0.
wa_final-v_erc = wa_bseg-wrbtr / wa_final-dmbtr1.
ENDIF.
IF wa_final-v_erc NE 0.
wa_final-v_op = wa_ekpo-netpr / wa_final-v_erc.
ENDIF.
wa_final-v_uos = wa_mbew-stprs - wa_final-v_op.
wa_final-v_io = wa_final-v_iv + wa_final-v_uos.
wa_final-v_uv = wa_final-v_uos + wa_final-v_io.
wa_final-v_t = wa_final-v_uv + wa_bseg-menge.
wa_final-v_d = wa_final-v_t - wa_final-v_alc.
wa_final-v_os = wa_final-v_uos * wa_bseg-menge.
wa_final-v_ito = wa_final-v_io * wa_bseg-menge.
CLEAR wa_bseg.
APPEND wa_final TO i_final.
CLEAR wa_final.
ENDLOOP.
ENDIF.
ENDFORM. "data_retrieval
*& Form build_fieldcat
text
--> p1 text
<-- p2 text
FORM build_fieldcat.
CLEAR wa_fieldcat.
* TYPES : v_alc TYPE dmbtr. "curr. " decimal 2.
DATA: l_c_v_alc TYPE p DECIMALS 2,
l_c_v_iv TYPE p DECIMALS 2 .
l_c_v_alc = v_alc.
l_c_v_iv = v_iv.
Constant Declarations.
CONSTANTS:
l_c_gjahr(5) TYPE c VALUE 'GJAHR', " Year
l_c_wwert(5) TYPE c VALUE 'WWERT', " Traslation date
l_c_bukrs(5) TYPE c VALUE 'BUKRS', " company code
l_c_hkont(5) TYPE c VALUE 'HKONT', " General ledger account
l_c_txt20(10) TYPE c VALUE 'TXT20', " Account name
l_c_belnr(5) TYPE c VALUE 'BELNR', " Doc number
l_c_shkzg(5) TYPE c VALUE 'SHKZG', " Dt/Cr indicator
l_c_dmbtr(5) TYPE c VALUE 'DMBTR1', " Ammount in local currency
" l_c_v_alc TYPE c VALUE 'V_ALC', " Ammount in local currency
l_c_wrbtr(5) TYPE c VALUE 'WRBTR', " Ammount in foreign currency
l_c_ebeln(5) TYPE c VALUE 'EBELN', " Purchase order number
l_c_ebelp(5) TYPE c VALUE 'EBELP', " Item number
l_c_matnr(5) TYPE c VALUE 'MATNR', " Material number
l_c_menge(7) TYPE c VALUE 'MENGE', " Qunatity
l_c_meins(5) TYPE c VALUE 'MEINS', " Unit of measure
l_c_stprs(5) TYPE c VALUE 'STPRS', " Std material master
" l_c_v_iv(4) TYPE c VALUE 'V_IV', " Invoice value
l_c_pswsl(5) TYPE c VALUE 'PSWSL', " Currency
l_c_v_erc(5) TYPE c VALUE 'V_ERC', " Exchange rate calculated
l_c_v_op(4) TYPE c VALUE 'V_OP', " Order price
l_c_v_uos(5) TYPE c VALUE 'V_UOS', " Unit order to stock
l_c_v_io(4) TYPE c VALUE 'V_IO', " Invoice to order
l_c_v_uv(4) TYPE c VALUE 'V_UV', " Unit value
l_c_v_t(3) TYPE c VALUE 'V_T', " Total
l_c_v_d(3) TYPE c VALUE 'V_D', " Differecne
l_c_netpr(5) TYPE c VALUE 'NETPR', " Net price in purchasing document
l_c_v_total(7) TYPE c VALUE 'V_TOTAL', " Total
l_c_v_os(4) TYPE c VALUE 'V_OS', " Order to stock
l_c_v_ito(5) TYPE c VALUE 'V_ITO', " Invoice to order
l_c_saknr(5) TYPE c VALUE 'SAKNR', " G/L account number
l_c_i_final(7) TYPE c VALUE 'I_FINAL'. " Final internal table
Fieldcat for fiscal year
wa_fieldcat-col_pos = 1.
wa_fieldcat-tabname = l_c_i_final.
wa_fieldcat-fieldname = l_c_gjahr.
wa_fieldcat-seltext_m = text-007.
APPEND wa_fieldcat TO i_fieldcat.
CLEAR wa_fieldcat.
Fieldcat for Translation date
wa_fieldcat-col_pos = 2.
wa_fieldcat-tabname = l_c_i_final.
wa_fieldcat-fieldname = l_c_wwert.
wa_fieldcat-seltext_m = text-008.
APPEND wa_fieldcat TO i_fieldcat.
CLEAR wa_fieldcat.
Fieldcat for Company code
wa_fieldcat-col_pos = 3.
wa_fieldcat-tabname = l_c_i_final.
wa_fieldcat-fieldname = l_c_bukrs.
wa_fieldcat-seltext_m = text-009.
APPEND wa_fieldcat TO i_fieldcat.
CLEAR wa_fieldcat.
Fieldcat for General ledger account
wa_fieldcat-col_pos = 4.
wa_fieldcat-tabname = l_c_i_final.
wa_fieldcat-fieldname = l_c_hkont.
wa_fieldcat-seltext_m = text-010.
APPEND wa_fieldcat TO i_fieldcat.
CLEAR wa_fieldcat.
Fieldcat for Account name
wa_fieldcat-col_pos = 5.
wa_fieldcat-tabname = l_c_i_final.
wa_fieldcat-fieldname = l_c_txt20.
wa_fieldcat-seltext_m = text-011.
APPEND wa_fieldcat TO i_fieldcat.
CLEAR wa_fieldcat.
Fieldcat for Doc number
wa_fieldcat-col_pos = 6.
wa_fieldcat-tabname = l_c_i_final.
wa_fieldcat-fieldname = l_c_belnr.
wa_fieldcat-seltext_m = text-012.
APPEND wa_fieldcat TO i_fieldcat.
CLEAR wa_fieldcat.
Fieldcat for Dt/Cr indicator
wa_fieldcat-col_pos = 7.
wa_fieldcat-tabname = l_c_i_final.
wa_fieldcat-fieldname = l_c_shkzg.
wa_fieldcat-seltext_m = text-013.
APPEND wa_fieldcat TO i_fieldcat.
CLEAR wa_fieldcat.
Fieldcat for Ammount in local currency
wa_fieldcat-col_pos = 8.
wa_fieldcat-tabname = l_c_i_final.
wa_fieldcat-fieldname = 'DMBTR1'.
wa_fieldcat-seltext_m = text-014.
APPEND wa_fieldcat TO i_fieldcat.
CLEAR wa_fieldcat.
Fieldcat for Ammount in local currency
wa_fieldcat-col_pos = 9.
wa_fieldcat-tabname = l_c_i_final.
wa_fieldcat-fieldname = 'V_ALC'.
wa_fieldcat-seltext_m = text-015.
wa_fieldcat-ref_fieldname = 'DMBTR'.
wa_fieldcat-no_sign = 'X'.
wa_fieldcat-do_sum = c_x.
APPEND wa_fieldcat TO i_fieldcat.
CLEAR wa_fieldcat.
Fieldcat for Ammount in foreign currency
wa_fieldcat-col_pos = 10.
wa_fieldcat-tabname = l_c_i_final.
wa_fieldcat-fieldname = l_c_wrbtr.
wa_fieldcat-seltext_m = text-016.
APPEND wa_fieldcat TO i_fieldcat.
CLEAR wa_fieldcat.
Fieldcat for Purchse order number
wa_fieldcat-col_pos = 11.
wa_fieldcat-tabname = l_c_i_final.
wa_fieldcat-fieldname = l_c_ebeln.
wa_fieldcat-seltext_m = text-017.
APPEND wa_fieldcat TO i_fieldcat.
CLEAR wa_fieldcat.
Fieldcat for Item No
wa_fieldcat-col_pos = 12.
wa_fieldcat-tabname = l_c_i_final.
wa_fieldcat-fieldname = l_c_ebelp.
wa_fieldcat-seltext_m = text-018.
APPEND wa_fieldcat TO i_fieldcat.
CLEAR wa_fieldcat.
Fieldcat for Material number
wa_fieldcat-col_pos = 13.
wa_fieldcat-tabname = l_c_i_final.
wa_fieldcat-fieldname = l_c_matnr.
wa_fieldcat-seltext_m = text-019.
APPEND wa_fieldcat TO i_fieldcat.
CLEAR wa_fieldcat.
Fieldcat for Qunatity
wa_fieldcat-col_pos = 14.
wa_fieldcat-tabname = l_c_i_final.
wa_fieldcat-fieldname = l_c_menge.
wa_fieldcat-seltext_m = text-020.
APPEND wa_fieldcat TO i_fieldcat.
CLEAR wa_fieldcat.
Fieldcat for Unit of measure
wa_fieldcat-col_pos = 15.
wa_fieldcat-tabname = l_c_i_final.
wa_fieldcat-fieldname = l_c_meins.
wa_fieldcat-seltext_m = text-021.
APPEND wa_fieldcat TO i_fieldcat.
CLEAR wa_fieldcat.
Fieldcat for Std material master
wa_fieldcat-col_pos = 16.
wa_fieldcat-tabname = l_c_i_final.
wa_fieldcat-fieldname = l_c_stprs.
wa_fieldcat-seltext_m = text-022.
APPEND wa_fieldcat TO i_fieldcat.
CLEAR wa_fieldcat.
Fieldcat for Invoice value,
wa_fieldcat-col_pos = 17.
wa_fieldcat-tabname = l_c_i_final.
wa_fieldcat-fieldname = 'V_IV'.
wa_fieldcat-seltext_m = text-023.
wa_fieldcat-ref_fieldname = 'DMBTR'.
APPEND wa_fieldcat TO i_fieldcat.
CLEAR wa_fieldcat.
Fieldcat for Currency
wa_fieldcat-col_pos = 18.
wa_fieldcat-tabname = l_c_i_final.
wa_fieldcat-fieldname = l_c_pswsl.
wa_fieldcat-seltext_m = text-024.
APPEND wa_fieldcat TO i_fieldcat.
CLEAR wa_fieldcat.
Fieldcat for Exchange rate calculated
wa_fieldcat-col_pos = 19.
wa_fieldcat-tabname = l_c_i_final.
wa_fieldcat-fieldname = 'V_ERC'.
wa_fieldcat-seltext_m = text-025.
APPEND wa_fieldcat TO i_fieldcat.
CLEAR wa_fieldcat.
Fieldcat for Order price
wa_fieldcat-col_pos = 20.
wa_fieldcat-tabname = l_c_i_final.
wa_fieldcat-fieldname = l_c_v_op.
wa_fieldcat-seltext_m = text-026.
APPEND wa_fieldcat TO i_fieldcat.
CLEAR wa_fieldcat.
Fieldcat for Unit order to stock
wa_fieldcat-col_pos = 21.
wa_fieldcat-tabname = l_c_i_final.
wa_fieldcat-fieldname = l_c_v_uos.
wa_fieldcat-seltext_m = text-027.
wa_fieldcat-do_sum = c_x.
APPEND wa_fieldcat TO i_fieldcat.
CLEAR wa_fieldcat.
Fieldcat for Invoice to order
wa_fieldcat-col_pos = 22.
wa_fieldcat-tabname = l_c_i_final.
wa_fieldcat-fieldname = l_c_v_io.
wa_fieldcat-seltext_m = text-028.
APPEND wa_fieldcat TO i_fieldcat.
CLEAR wa_fieldcat.
Fieldcat for Unit value
wa_fieldcat-col_pos = 23.
wa_fieldcat-tabname = l_c_i_final.
wa_fieldcat-fieldname = l_c_v_uv.
wa_fieldcat-seltext_m = text-029.
APPEND wa_fieldcat TO i_fieldcat.
CLEAR wa_fieldcat.
Fieldcat for Total
wa_fieldcat-col_pos = 24.
wa_fieldcat-tabname = l_c_i_final.
wa_fieldcat-fieldname = l_c_v_t.
wa_fieldcat-seltext_m = text-030.
APPEND wa_fieldcat TO i_fieldcat.
CLEAR wa_fieldcat.
Fieldcat for Difference
wa_fieldcat-col_pos = 25.
wa_fieldcat-tabname = l_c_i_final.
wa_fieldcat-fieldname = l_c_v_d.
wa_fieldcat-seltext_m = text-031.
APPEND wa_fieldcat TO i_fieldcat.
CLEAR wa_fieldcat.
Fieldcat for Net Price in Purchasing Document
wa_fieldcat-col_pos = 26.
wa_fieldcat-tabname = l_c_i_final.
wa_fieldcat-fieldname = l_c_netpr.
wa_fieldcat-seltext_m = text-032.
APPEND wa_fieldcat TO i_fieldcat.
CLEAR wa_fieldcat.
Fieldcat for Total
wa_fieldcat-col_pos = 27.
wa_fieldcat-tabname = l_c_i_final.
wa_fieldcat-fieldname = l_c_v_total.
wa_fieldcat-seltext_m = text-033.
APPEND wa_fieldcat TO i_fieldcat.
CLEAR wa_fieldcat.
Fieldcat for Order to stock
wa_fieldcat-col_pos = 28.
wa_fieldcat-tabname = l_c_i_final.
wa_fieldcat-fieldname = l_c_v_os.
wa_fieldcat-seltext_m = text-034.
APPEND wa_fieldcat TO i_fieldcat.
CLEAR wa_fieldcat.
Fieldcat for Invoice to order
wa_fieldcat-col_pos = 29.
wa_fieldcat-tabname = l_c_i_final.
wa_fieldcat-fieldname = l_c_v_ito.
wa_fieldcat-seltext_m = text-035.
APPEND wa_fieldcat TO i_fieldcat.
CLEAR wa_fieldcat.
fieldcat for invoice to order
wa_fieldcat-col_pos = 30.
wa_fieldcat-tabname = l_c_i_final.
wa_fieldcat-fieldname = l_c_saknr.
wa_fieldcat-seltext_m = text-035.
APPEND wa_fieldcat TO i_fieldcat.
CLEAR wa_fieldcat.
ENDFORM. "build_fieldcatHi romanch,
defining the field catalog you must reference all currency fields to the respective currency key field (type CUKY).
<alv_fieldcat>-cfieldname = 'HWAER'.
This is sample for alv output of a currency field. The alv structure has a field HWAER which carries the currency key, e.g. USD or so.
Obviously you do not provide a cutrrency key for your values. If they are initial (zero), ALV will not display them as 0,00 but leave the field empty if the reference too currency key is not established.
If you define a DDIC structure for the ALV output this refernce is enforced. You can pass the DDIC structure name to the ALV and don not have to create the field catalog manually.
Regards,
Clemens -
Problem in move the data to final internal table.
hi,
iam having 3 internal table.
1. g_t_vbrk (having data for vbrk table)
2. g_t_vbak (having data for vbak table)
3. g_t_likp (having data for likp table.)
actually i have written the loop like below .
LOOP AT g_t_vbrk.
READ TABLE g_t_vbfa WITH KEY vbeln = g_t_vbrk-vbeln.
IF sy-subrc = 0.
MOVE : g_t_vbrk-vbeln TO g_t_output_raw_header_data-vbeln,
g_t_vbrk-taxk1 TO g_t_output_raw_header_data-taxk1,
g_t_vbrk-taxk4 TO g_t_output_raw_header_data-taxk4,
g_t_vbrk-fkart TO g_t_output_raw_header_data-fkart,
g_t_vbrk-inco1 TO g_t_output_raw_header_data-inco1,
g_t_vbrk-inco2 TO g_t_output_raw_header_data-inco2,
g_t_vbrk-zterm TO g_t_output_raw_header_data-zterm,
g_t_vbrk-kunag TO g_t_output_raw_header_data-kunag.
READ TABLE g_t_vbak WITH KEY vbeln = g_t_vbfa-vbelv.
IF sy-subrc = 0.
MOVE : g_t_vbak-vkorg TO g_t_output_raw_header_data-vkorg,
g_t_vbak-auart TO g_t_output_raw_header_data-auart,
g_t_vbak-spart TO g_t_output_raw_header_data-spart,
g_t_vbak-vtweg TO g_t_output_raw_header_data-vtweg.
ENDIF.
APPEND g_t_output_raw_header_data.
endloop.
my question is i want to move likp table lfdat field to that final internal table with same loop.
i want to write move statement with same loop.
pls help with coding wise.
thanks
santhoshHi
In the loop.
SELECT VBELN FROM VBFA
INTO V_VBELN
WHERE VBELV = G_I_VBRK-VBELN
AND VBTYP_N = 'M'
AND VBTYP_V = 'J'.
Now READ from your LIKP internal table.
READ TABLE G_I_LIKP WITH KEY VBELN = V_VBELN.
Write your MOVE statements here.
Regards
Surya. -
Need to move the data to final internal Table
Hi all,
TYPES: BEGIN OF TY_MARA,
MATNR TYPE MATNR, " Material Number
ZZBASE_CODE TYPE ZBASE_CODE, " Base Code
END OF TY_MARA,
BEGIN OF TY_MAKT,
MAKTX TYPE MAKTX, " Material Description
END OF TY_MAKT,
BEGIN OF TY_MARC,
WERKS TYPE WERKS_D, " Plant
END OF TY_MARC,
BEGIN OF TY_QMAT,
ART TYPE QPART, " Inspection Type
END OF TY_QMAT,
BEGIN OF TY_MAPL,
MATNR TYPE MATNR, " Material
PLNTY TYPE PLNTY, " Task List Type
END OF TY_MAPL,
BEGIN OF TY_PLKO,
VERWE TYPE PLN_VERWE, " Task list usage
END OF TY_PLKO,
BEGIN OF TY_FINAL,
MATNR TYPE MATNR, " Material Number
MAKTX TYPE MAKTX, " Material Description
ZZBASE_CODE TYPE ZBASE_CODE, " Base Code
WERKS TYPE WERKS_D, " Plant
CLASS TYPE KLASSE_D, " Class Number
ART TYPE QPART, " Inspection Type
VERWE TYPE PLN_VERWE, " Task list usage
END OF TY_FINAL.
DATA: I_MARA TYPE STANDARD TABLE OF TY_MARA ,
I_MAKT TYPE STANDARD TABLE OF TY_MAKT ,
I_MARC TYPE STANDARD TABLE OF TY_MARC ,
I_QMAT TYPE STANDARD TABLE OF TY_QMAT ,
I_MAPL TYPE STANDARD TABLE OF TY_MAPL ,
I_PLKO TYPE STANDARD TABLE OF TY_PLKO ,
I_KLAH TYPE STANDARD TABLE OF TY_KLAH ,
I_FINAL TYPE STANDARD TABLE OF TY_FINAL ,
WA_MARA TYPE TY_MARA,
WA_MAKT TYPE TY_MAKT,
WA_MARC TYPE TY_MARC,
WA_QMAT TYPE TY_QMAT,
WA_MAPL TYPE TY_MAPL,
WA_PLKO TYPE TY_PLKO,
WA_KLAH TYPE TY_KLAH,
WA_FINAL TYPE TY_FINAL.
data: v_mtart type mara-mtart,
v_matnr type mara-matnr,
v_zzbase_code type mara-zzbase_code,
v_werks type t001w-werks,
v_beskz type marc-beskz.
selection-screen skip 1.
selection-screen begin of block b1 with frame title text-001.
select-options: s_mtart for v_mtart default 'halb' to 'zraw',
s_matnr for v_matnr,
s_zzbase for v_zzbase_code,
s_werks for v_werks obligatory,
s_beskz for v_beskz.
selection-screen end of block b1.
start-of-selection.
select matnr
zzbase_code
from mara into table i_mara
where mtart in s_mtart "Material Type
and matnr in s_matnr "Material
and zzbase_code in s_zzbase."Base Code
select maktx
from makt into table i_makt for all entries in i_mara
where matnr = i_mara-matnr.
select werks
from marc into table i_marc for all entries in i_mara
where matnr = i_mara-matnr
and werks in s_werks "plant
and beskz in s_beskz."Procurement Type
select art
from qmat into table i_qmat for all entries in i_mara
where matnr = i_mara-matnr
and werks in s_werks.
select matnr
plnty from mapl into table i_mapl for all entries in i_mara
where matnr = i_mara-matnr.
select verwe
from plko into table i_plko for all entries in i_mapl
where plnty = i_mapl-plnty.
this is my logic . i need to move this to final internal table i_final. how can do it. will anybody tell me with coding.
Thanks,Hi,
Include matnr field in all your type declaration and plnty in the ty_plko, type declaration.
loop at the internal table i_mara.
read the other tables with read statement.
assign the the required fields to the work area wa_final. Append it to i_final.
start-of-selection.
select matnr zzbase_code
from mara into table i_mara
where mtart in s_mtart "Material Type and matnr in s_matnr "Material and zzbase_code in s_zzbase. "Base Code
select matnr maktx
from makt into table i_makt
for all entries in i_mara where matnr = i_mara-matnr.
select matnr werks
from marc into table i_marc
for all entries in i_mara where matnr = i_mara-matnr and werks in s_werks "plant and beskz in s_beskz."Procurement Type
select matnr art
from qmat into table i_qmat
for all entries in i_mara where matnr = i_mara-matnr and werks in s_werks.
select matnr plnty
from mapl into table i_mapl
for all entries in i_mara where matnr = i_mara-matnr.
select plnty verwe
from plko into table i_plko
for all entries in i_mapl where plnty = i_mapl-plnty.
Loop at i_mara into wa_mara.
read table i_makt into wa_makt with key matnr = wa_mara-matnr.
(do this for all the internal tables.)
read table i_plko into wa_plko with key plnty = wa_mapl-plnty.
wa_final-MATNR = wa_mara-matnr.
wa_final-MAKTX = wa_makt-maktx.
wa_final-ZZBASE_CODE = wa_mara-ZZBASE_CODE.
wa_final-WERKS = wa_marc-werks.
wa_final-ART = wa_qmat-art.
wa_final-VERWE = wa_plko-verve.
append i_final from wa_final.
endloop.
Hope this helps.
Regards,
Dhasarathy. K -
Dynamic access to the fields of an internal table
Hi,
Currently i'm having 10 fields in 1 internal table, and i need to validate this 10 fields but i dont like have too many "if and endif" statement. Is there any option to write an dynamic code.
Example
Data: begin of table,
field1 type c,
field2 type c,
field3 type c,
field4 type c,
field10 type c,
end of table.
Let say i want to fill field1 with 1, field2 with 2,........................... field10 with 10.
So instead of using this code
table-field1 = '1'.
table-field2 = '2'.
table-field3 = '3'.
table-field10 = '10'.
Can i do something dynamic like this
DO 10 times.
Dynamic coding, any idea ?
ENDDO.
<Modified the subject line>
Edited by: Suhas Saha on Jul 12, 2011 4:27 PMHi,
Sorry may my question is not detail enough. I would like to read the field from the internal table dynamically.
Data: begin of table,
field1 type c,
field2 type c,
field3 type c,
field4 type c,
field10 type c,
end of table.
Let say i want to fill field1 with 1, field2 with 2,........................... field10 with 10.
So instead of using this code
table-field1 = '1'.
table-field2 = '2'.
table-field3 = '3'.
table-field10 = '10'.
IF table-field1 < 0,
endif.
IF table-field2 < 0,
endif.
IF table-field3 < 0,
endif.
|
IF table-field10 < 0,
endif.
Can i do something dynamic like this
DO 10 times.
Dynamic coding, any idea ?
ENDDO. -
Moving the data from multiple internal tables into a single one
Hello everyone,
I am creating a classical report which uses the following tables.
tables : ekko, ekpo, mara, makt,lfa1.
my input parameter is
Select-options Purchase Order number
Following fields are getting used.
Doc no EKKO-EBELN
Material EKPO-MATNR
Item number EKPO-EBELP
Quantity EKPO-MENGE
Material Group MARA-MATKL
Vendor EKKO-LIFNR
Old Material code MARA-BISMT
Material Desc. MAKT-MAKTX
Vendor name LFA1-NAME1
Now i need to do the following task.
1 Select record from EKKO Using document number.
2 Select record from EKPO using EKKO record using Document no as key.
3 Find out Old Material code of each and every material from Material master.
4 Find out Material description for each and every material from MAKT.
5 Sort record on Vendor, Purchase Order number and Material.
I have defined seperate internal tables for these operation.
Once i have fetched records into these individual internal tables from the corresponding DB tables i need to move these values into a new internal tables which has all the above fields mentioned
I need to move these values into a new internal table because to display the values on the report.
Any idea for the above ? Plz help with a sample example or some relevant.
Regards,
Ranjith NambiarHi
1 Select record from EKKO Using document number.
2 Select record from EKPO using EKKO record using Document no as key.
Use inner join and retrive data into one internal table.for Ex ITAB1
3 Find out Old Material code of each and every material from Material master.
Use ITAB1 with for allentries in MARA table to get the onl materil number populate in to one table.
4 Find out Material description for each and every material from MAKT.
Get the Material desc with the same manner as above,
5 Sort record on Vendor, Purchase Order number and Material.
now sort the ITAB1 as you req.
now Loop on the ITAB1.
and read above 2 tables for old matnr and matner deac and append into another table as you want.
Hope this will help.
Regards,
Hiren Patel -
To pass the value to final internal table
hi all,
in the report i have a select query has below
SELECT SINGLE belnr
INTO (l_belnr)
FROM bkpf
WHERE bukrs = ls_bseg-bukrs
AND gjahr = ls_bseg-gjahr.
i have an internal table gt_values , in this almost i have 1500 entries.
with field has BELNR.
now i need to check l_belnr exists in GT_VALUES-BELNR OR NOT.
IF EXISTS i need to pass the belnr to GV_BELNR.
do we need to use LOOP and ENDLOOP or we have any other option.
PLEASE help me how to proceed in writing code for this.Use read table statement.
Read table GT_VALUES with key belnr = l_belnr.
if sy-subrc = 0.
move l_belnr to GV_BELNR.
endif. -
Moving the record to another internal table.
dear all,
i am having two internal tables . itab & itab1.
itab contains matnr plant quantity date
100 500 1000 yyyy/mm/10
100 500 2000 yyyy/mm/20.
i have to move the records to itab1 if dd less than 15 quantity should be moved to q1 if gt 15 then the quantity should be moved to same q2 in a same line.
i want itab1 to be
matnr plant q1 q2
100 500 1000 2000.
regards ,
balajihi Balaji,
Please use the following logic:
data:
v_dd(2).
loop at itab.
itab1-matnr = itab-matnr.
itab1-plant = itab-plant.
v_dd = itab-date+8(2).
read table itab1 with key matnr = itab1-matnr
plant = itab1-plant.
if v_dd < 15.
itab1-q1 = itab1-q1 + itab-quantity.
else.
itab1-q2 = itab1-q2 + itab-quantity.
endif.
if sy-subrc = 0.
modify itab1 index sy-tabix.
else.
append itab1.
endif.
clear itab1.
endloop.
Hope this helps,
Sajan Joseph. -
Moving the data of five internal tables to one internal tables.
iam having the five internal table. like below
g_t_vbfa
g_t_vbrk
g_t_vbpa
g_t_kna1
g_t_vbak
this are the five internal tables. each tables having the datas . but each table having the number of records is different. one table having 100 records means another table having 50 records.
previously i used index sys-tabix concept it was not working properly...
my output table is g_t_output_header_data ..
i want to move that output table....
please coding wise give some solution...
thanks
santhoshhi,
chk a sample.
data : begin of itab1 occurs 0. "itab with work area.
key_field1 like ztable1-key_field1,
field1 like ztable1-field1,
field2 like ztable1-field2,
endof itab1.
data : begin of itab2 occurs 0. "itab with work area.
key_field2 like ztable2-key_field2,
field3 like ztable2-field3,
field4 like ztable2-field4,
endof itab2.
data : begin of itab_final occurs 0.
key_field1 like ztable1-key_field1,
field1 like ztable1-field1,
field2 like ztable1-field2,
field3 like ztable2-field3,
field4 like ztable2-field4,
endof itab_final.
put the date final(merged) internal table
1. loop at itab1.
read table itab2 with key keyfield2 = itab1-keyfield1.
if sy-surc = 0.
itab_final-key_field1 = itab1-keyfield1
itab_final-field1 = itab1-field1.
itab_final-field2 = itab1-keyfield2.
itab_final-field3 = itab2-field2.
itab_final-field4 = itab2-keyfield2.
append itab_final.
clear itab_final.
endif.
endloop.
or
LOOP AT ITAB1.
MOVE-CORRESPONDING TO ITAB1 to ITAB_FINAL.
READ TABLE ITAB2 WITH KEY FILED1 = ITAB1-FIELD1.
if sy-subrc = 0.
MOVE-CORRESPONDING TO ITAB2 to ITAB_FINAL.
endif,
READ TABLE ITAB3 WITH KEY FILED1 = ITAB1-FIELD1.
if sy-subrc = 0.
MOVE-CORRESPONDING TO ITAB2 to ITAB_FINAL.
endif,
append itab_final.
clear itab_final.
endloop
rgds
Anver -
Appending All the fields of one internal table to other
Hi,
while running a FM I get three internal tables, my requirement is that I am running this FM at item level if it is possible to append all the tables datas get as a result of this FM to other internal table having same structure.
I know it is possible while using loop, I need a solution with out using the loop
Regards
NausalMove Itab1[] to itab2[].
data: begin of itab occurs 0,
Maktx LIKE MAKT-MAKTX,
end of itab.
data: begin of itab1 occurs 0,
Maktx LIKE MAKT-MAKTX,
end of itab1.
select maktx from makt into table itab where maktx like 'M1%'.
move itab[] to itab1[].
loop at itab1.
write:/ itab1-maktx.
endloop. -
Field catalog for internal table in ALV
In my program the internal table consists many fields from various tables and structure doesn't belong to a single data table.
In order to get output in ALV grid following FM has been used
REUSE_ALV_GRID_DISPLAY
for field catalog the fields are defined specifically.
l_fieldcat-fieldname = 'VBELN'.
l_fieldcat-outputlen = 10.
l_fieldcat-seltext_l = 'Billing doc'.
l_fieldcat-no_zero = 'X'.
l_fieldcat-hotspot = 'X'.
append l_fieldcat to p_fieldtab.
..............and so on for all the fields.
Just wanted to know is there any other method to display all the fields of this internal table automatically so each field is not specified specifically.
anyaHi
Try this instead:
*& Form create_fieldcatalog
* Create a field catalogue from any internal table
* -->PT_TABLE Internal table
* -->PT_FIELDCAT Field Catalogue
FORM create_fieldcatalog
USING pt_table TYPE ANY TABLE
CHANGING pt_fieldcat TYPE lvc_t_fcat.
DATA:
lr_tabdescr TYPE REF TO cl_abap_structdescr
, lr_data TYPE REF TO data
, lt_dfies TYPE ddfields
, ls_dfies TYPE dfies
, ls_fieldcat TYPE lvc_s_fcat
CLEAR pt_fieldcat.
CREATE DATA lr_data LIKE LINE OF pt_table.
lr_tabdescr ?= cl_abap_structdescr=>describe_by_data_ref( lr_data ).
lt_dfies = cl_salv_data_descr=>read_structdescr( lr_tabdescr ).
LOOP AT lt_dfies
INTO ls_dfies.
CLEAR ls_fieldcat.
MOVE-CORRESPONDING ls_dfies TO ls_fieldcat.
APPEND ls_fieldcat TO pt_fieldcat.
ENDLOOP.
ENDFORM. "create_fieldcatalog -
Dynamic field access in internal tables
Hi everyone.
I woulkd like to know if there is any way to identify the fields of an internal table at runtime. I'm creating a method in a class, and i would like to accept any itab as a paramter and then access the fields of that itab. I currently have the itab passing no problem using field symbols, and i am able to loop at the data, but i am unsure how to get the field names.
Any suggestions?
Thanks!Hi,
Check the code below:
REPORT ZYKTEST3 .
DATA: d_ref TYPE REF TO data,
d_ref2 TYPE REF TO data,
i_alv_cat TYPE TABLE OF lvc_s_fcat,
ls_alv_cat LIKE LINE OF i_alv_cat.
TYPES: tabname LIKE dcobjdef-name ,
fieldname LIKE dcobjdef-name,
desc LIKE dntab-fieldtext.
PARAMETER: p_tablen TYPE tabname. -
> Input table field
DATA: BEGIN OF itab OCCURS 0.
INCLUDE STRUCTURE dntab.
DATA: END OF itab.
FIELD-SYMBOLS : <f_fs> TYPE table,
<f_fs1> TYPE table,
<f_fs2> TYPE ANY,
<f_fs3> TYPE ANY,
<f_fs4> type any,
<f_field> TYPE ANY.
REFRESH itab.
CALL FUNCTION 'NAMETAB_GET' -
> Fetches the fields
EXPORTING
langu = sy-langu
tabname = p_tablen
TABLES
nametab = itab
EXCEPTIONS
no_texts_found = 1.
LOOP AT itab .
ls_alv_cat-fieldname = itab-fieldname.
ls_alv_cat-ref_table = p_tablen.
ls_alv_cat-ref_field = itab-fieldname.
ls_alv_cat-seltext = itab-fieldtext.
ls_alv_cat-reptext = itab-fieldtext.
APPEND ls_alv_cat TO i_alv_cat.
ENDLOOP.
internal table build
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = i_alv_cat
IMPORTING
ep_table = d_ref.
ASSIGN d_ref->* TO <f_fs>. -
> Dynamic table creation with fields of the table
DATA: l_field TYPE fieldname,
l_field1 type fieldname.
SELECT * FROM (p_tablen) INTO CORRESPONDING FIELDS OF TABLE <f_fs>.
Fetching of the data from the table
LOOP AT <f_fs> ASSIGNING <f_fs2>.
Here u can check the validations and process
ASSIGN COMPONENT 2 OF STRUCTURE <f_fs2> TO <f_fs3>.
ASSIGN COMPONENT 3 OF STRUCTURE <f_fs2> TO <f_fs4>.
IF sy-subrc = 0.
MOVE <f_fs3> TO l_field.
MOVE <f_fs4> TO l_field1.
WRITE:/1 l_field(20),
22 l_field1(10).
ENDIF.
ENDLOOP.
Regards
Kannaiah
Maybe you are looking for
-
Return/exchange policies?
I find the potential for problems with the new MB overwhelming. I don't think I could live with a MB with problems. What happens if you get a MB that you think has something wrong with it? What can you do? What if you have one that makes a noise and
-
Macbook Pro can no longer connect to any wirless connection
My macbook pro has never had any problem connecting to a wireless connection up until recently. For the last two months, I have not been able to connect to any wireless signal although I can when connected directly to the router with a lan cable. the
-
Playback gives black screen after a few times
Hi! This is my problem. I just installed Adobe Premiere CS6. After trying it a few hours the program has allready frozen a dozen times and unexpectedly quit a few times. Is there some major bugs in the CS6? (One of the recurring problems is the playb
-
Error 54 in udp write when sending to ip 127.0.0.1 !
hello friends ! i have installed labview 2012 and my projects (which i wrote in labview 2010) have some incompatibility issues. one of them is error 54 (the network address is ill-formed etc...) when trying to send data to myself - to IP 127.0.0.1 in
-
Question about BatchPara and what is going on here. I went to index cube ZBM_C021 in BWA (ver 53) and see the following in the Job output: 12/08/2009 14:00:15 INFOCUBE: ZBM_C021 12/08/2009 14:00:15 Statistics UID of indexing job: '4G3O2H296L13RHNVBY7