Dynamic ALV and internal table.
Hi all,
I have a requirement of creating a dynamic field catelog based on input values in selection screen.
Example:
1) When I enter date range, say 20/03/2008 to 25/03/2008 I should have 6 columns in the output for each date with column heading as date itself.
2) For entering values for these date columns, i need to create an dynamic internal table.(values in the column will be some numbers like 10 on 20/03/2008, 15 on 21/03/2008 etc)
A rough output format would look like this:
Component | 20/03/2008 | 21/03/2008 | ..... |25/03/2008
comp1 | 10 | 15 | | 5
comp2 | 20 | 10 | | 10
Please let me know how can i achieve this...
Need it very urgently..
Regards,
Dhareppa
Hi Dhareppa,
Refer the code below. Its almost on the same line as your requirments.
REPORT zglo2fr_master_planing_sedul NO STANDARD PAGE HEADING.
P R O G R A M H E A D E R *
ArthroCare Corporation *
Program : ZGLO2FR_MASTER_PLANING_SEDUL *
Author : Munvar Basha *
Creation Date : 11Mar08 *
Release : SAP ECC 6.0 *
Request : D01K904032 *
Description : Master Schedule Planning *
Change log (Revisions) *
Author Date Request Description *
P R O G R A M *
DATA DECLARATION *
**--Structure to hold matrial & plant combination records.
TYPES : BEGIN OF ty_marc,
matnr TYPE matnr,
werks TYPE werks_d,
dispo TYPE dispo,
beskz TYPE beskz,
mtart TYPE mtart,
END OF ty_marc.
**--structure to hold MRP LIST Data.
TYPES : BEGIN OF ty_mrp_list,
matnr TYPE matnr,
werks TYPE werks_d,
maktx TYPE maktx,
meins TYPE meins,
mtart TYPE mtart,
week TYPE kweek,
mng01 TYPE mng01,
delkz TYPE delkz,
END OF ty_mrp_list.
**--structure to hold no of weeks.
TYPES: BEGIN OF ty_week,
week TYPE kweek,
END OF ty_week.
**--structure to hold output data.
TYPES : BEGIN OF ty_final,
matnr TYPE matnr,
werks TYPE werks_d,
maktx TYPE maktx,
meins TYPE meins,
mtart TYPE mtart,
week TYPE kweek,
mng01 TYPE mng01,
END OF ty_final.
TYPES : BEGIN OF ty_range,
sign TYPE sign,
option TYPE option,
low TYPE sy-datum,
high TYPE sy-datum,
END OF ty_range.
Definitions of Table types. *
TYPES : ty_marctab TYPE STANDARD TABLE OF ty_marc.
Definitions of Ranges *
*RANGES ran_delkz FOR mdez-delkz.
DATA : i_ran_delkz TYPE RANGE OF mdez-delkz,
wa_ran_delkz LIKE LINE OF i_ran_delkz,
wa_date type ty_range.
Definitions of internal tables. *
data : i_marc type standard table of ty_marc,
i_mrp_list type standard table of ty_mrp_list,
i_week type standard table of ty_week,
i_final type standard table of ty_final,
i_mdps type standard table of mdps,
i_mdez type standard table of mdez,
i_mdsu type standard table of mdsu.
Definitions of work areas for internal tables *
DATA : wa_marc TYPE ty_marc,
wa_mrp_list TYPE ty_mrp_list,
wa_week TYPE ty_week,
wa_final TYPE ty_final,
wa_mt61d TYPE mt61d,
wa_mdez TYPE mdez.
Definitiions of General variables *
DATA : v_matnr TYPE mara-matnr, " Material Number
v_mtart TYPE mara-mtart, " Material Type
v_beskz TYPE marc-beskz, " Procurement Type
v_werks TYPE marc-werks, " Plant
v_dispo TYPE marc-dispo. " MRP Controller (Materials Planner)
DATA : v_mng01 TYPE mng01. "Requirement Quantity
DATA : v_year TYPE char4,
v_week TYPE char2,
v_ok_code TYPE sy-ucomm.
Definitiions of Constants *
CONSTANTS : k_slash TYPE c VALUE '/',
k_6 TYPE char8 VALUE '6',
k_x TYPE c VALUE 'X'.
Definitiions of Field Catlog *
DATA : wa_fieldcat TYPE lvc_s_fcat,
i_fieldcat TYPE lvc_t_fcat,
v_container TYPE scrfname VALUE 'CONTAINER_OUTPUT',
v_custom_container TYPE REF TO cl_gui_custom_container,
v_grid TYPE REF TO cl_gui_alv_grid,
i_gp_table TYPE REF TO data,
wa_gp_line TYPE REF TO data.
FIELD-SYMBOLS: <gt_table> TYPE STANDARD TABLE,
<gwa_table> TYPE ANY,
<l_field> TYPE ANY,
<l_matnr> TYPE ANY,
<l_werks> TYPE ANY,
<l_maktx> TYPE ANY,
<l_meins> TYPE ANY,
<l_mtart> TYPE ANY.
DECLERATIONS FOR SELECTION SCREEN *
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
SELECT-OPTIONS : s_matnr FOR v_matnr,
s_mtart FOR v_mtart NO INTERVALS,
s_beskz FOR v_beskz NO INTERVALS NO-EXTENSION,
s_werks FOR v_werks NO INTERVALS NO-EXTENSION
OBLIGATORY,
s_dispo FOR v_dispo,
s_date FOR sy-datum OBLIGATORY.
PARAMETERS : p_dattp TYPE dattp OBLIGATORY DEFAULT '1'.
SELECTION-SCREEN END OF BLOCK b1.
INITIALIZATION EVENT *
INITIALIZATION.
CALL FUNCTION '/BEV4/PLPS__ADD_MONTH_TO_DATE'
EXPORTING
months = k_6
olddate = sy-datum
IMPORTING
newdate = wa_date-high.
wa_date-low = sy-datum.
wa_date-option = 'EQ'.
wa_date-sign = 'I'.
APPEND wa_date to s_date.
SELECTION SCREEN EVENT *
**--Validation for Material
AT SELECTION-SCREEN ON s_matnr.
PERFORM validate_material.
**--Validation for Plant
AT SELECTION-SCREEN ON s_werks.
PERFORM validate_plant.
AT SELECTION-SCREEN ENENT *
AT SELECTION-SCREEN.
IF s_matnr IS INITIAL AND s_dispo IS INITIAL.
MESSAGE text-002 TYPE 'E'.
ENDIF.
IF s_date-low LT sy-datum.
MESSAGE text-003 TYPE 'E'.
ENDIF.
START-OF-SELECTION EVENT *
START-OF-SELECTION.
**--refreshing the internal tables
REFRESH : i_marc,
i_mrp_list,
i_week,
i_final,
i_mdps,
i_mdez,
i_mdsu.
**--clearing the work areas of internal tables.
CLEAR : wa_marc,
wa_mrp_list,
wa_week,
wa_final,
wa_mt61d,
wa_mdez.
To get all the matrial(s) and plant combination records
SELECT a~matnr
a~werks
a~dispo
a~beskz
b~mtart
INTO TABLE i_marc
FROM marc AS a INNER JOIN
mara AS b
ON a~matnr = b~matnr
WHERE a~werks IN s_werks AND
a~matnr IN s_matnr AND
a~dispo IN s_dispo AND
a~beskz IN s_beskz AND
b~mtart IN s_mtart.
IF sy-subrc <> 0.
MESSAGE text-005 TYPE 'S'.
LEAVE LIST-PROCESSING.
ENDIF.
SORT i_marc BY matnr werks.
Ranges to Filter the MRP list only for the following MRP Elements.
MRP Elements are : BA, BE, FE, LE and PA
wa_ran_delkz-sign = 'I'.
wa_ran_delkz-option = 'EQ'.
wa_ran_delkz-low = 'BA'.
APPEND wa_ran_delkz TO i_ran_delkz.
CLEAR wa_ran_delkz-low.
wa_ran_delkz-low = 'BE'.
APPEND wa_ran_delkz TO i_ran_delkz.
CLEAR wa_ran_delkz-low.
wa_ran_delkz-low = 'FE'.
APPEND wa_ran_delkz TO i_ran_delkz.
CLEAR wa_ran_delkz-low.
wa_ran_delkz-low = 'LE'.
APPEND wa_ran_delkz TO i_ran_delkz.
CLEAR wa_ran_delkz-low.
wa_ran_delkz-low = 'PA'.
APPEND wa_ran_delkz TO i_ran_delkz.
CLEAR wa_ran_delkz-low.
LOOP AT i_marc INTO wa_marc.
CALL FUNCTION 'MD_MRP_LIST_API'
EXPORTING
matnr = wa_marc-matnr
werks = wa_marc-werks
sinfg = k_x
inper = p_dattp
IMPORTING
e_mt61d = wa_mt61d
TABLES
mdpsx = i_mdps
mdezx = i_mdez
mdsux = i_mdsu
EXCEPTIONS
mrp_list_not_found = 1
material_plant_not_found = 2
error = 3
OTHERS = 4.
IF sy-subrc = 0.
LOOP AT i_mdez INTO wa_mdez WHERE dat00 IN s_date AND
delkz IN i_ran_delkz.
CALL FUNCTION 'DATE_GET_WEEK'
EXPORTING
date = wa_mdez-dat00
IMPORTING
week = wa_mrp_list-week
EXCEPTIONS
date_invalid = 1
OTHERS = 2.
IF sy-subrc = 0.
wa_mrp_list-matnr = wa_mt61d-matnr.
wa_mrp_list-werks = wa_mt61d-werks.
wa_mrp_list-maktx = wa_mt61d-maktx.
wa_mrp_list-meins = wa_mt61d-meins.
wa_mrp_list-mtart = wa_mt61d-mtart.
wa_mrp_list-delkz = wa_mdez-delkz.
wa_mrp_list-mng01 = wa_mdez-mng01.
APPEND wa_mrp_list TO i_mrp_list.
CLEAR : wa_mrp_list,
wa_mdez.
ENDIF.
ENDLOOP.
ENDIF.
CLEAR: wa_marc.
ENDLOOP.
IF i_mrp_list IS INITIAL.
MESSAGE text-006 TYPE 'S'.
LEAVE LIST-PROCESSING.
ENDIF.
CLEAR : v_mng01.
LOOP AT i_mrp_list INTO wa_mrp_list.
v_mng01 = v_mng01 + wa_mrp_list-mng01.
AT END OF week.
wa_final-matnr = wa_mrp_list-matnr.
wa_final-werks = wa_mrp_list-werks.
wa_final-maktx = wa_mrp_list-maktx.
wa_final-meins = wa_mrp_list-meins.
wa_final-mtart = wa_mrp_list-mtart.
wa_final-week = wa_mrp_list-week.
wa_final-mng01 = v_mng01.
wa_week-week = wa_mrp_list-week.
APPEND : wa_final TO i_final,
wa_week TO i_week.
CLEAR : v_mng01,
wa_final,
wa_week.
ENDAT.
CLEAR : wa_mrp_list.
ENDLOOP.
**-- Populate the Field catalog
PERFORM populate_fieldcat.
**--Create table dynamically
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = i_fieldcat
IMPORTING
ep_table = i_gp_table.
ASSIGN i_gp_table->* TO <gt_table>.
**--fill table with final output data
PERFORM fill_table.
CALL SCREEN 100.
SUB ROUTINES *
*& Form validate_material *
Validating Material Number(s) *
FORM validate_material .
TYPES : BEGIN OF l_ty_matnr,
matnr TYPE matnr,
END OF l_ty_matnr.
DATA : l_i_matnr TYPE STANDARD TABLE OF l_ty_matnr.
SELECT matnr
FROM mara
INTO TABLE l_i_matnr
WHERE matnr IN s_matnr.
IF sy-subrc <> 0.
MESSAGE text-004 TYPE 'E'.
ENDIF.
ENDFORM. " validate_material
*& Form validate_plant *
Validating Plant Number *
FORM validate_plant .
DATA : l_v_werks TYPE werks_d.
SELECT SINGLE werks
FROM t001w
INTO l_v_werks
WHERE werks = s_werks-low.
IF sy-subrc <> 0.
MESSAGE e019(zartc) WITH s_werks-low.
ENDIF.
ENDFORM. " validate_plant
*& Form populate_fieldcat
text
--> p1 text
<-- p2 text
FORM populate_fieldcat .
DATA : l_v_colname TYPE char7.
SORT i_week BY week.
DELETE ADJACENT DUPLICATES FROM i_week COMPARING week.
LOOP AT i_week INTO wa_week.
AT FIRST.
wa_fieldcat-row_pos = 0.
wa_fieldcat-col_pos = 1.
wa_fieldcat-fieldname = 'MATNR'.
wa_fieldcat-scrtext_l = text-007.
wa_fieldcat-scrtext_m = text-007.
wa_fieldcat-scrtext_s = text-007.
wa_fieldcat-fix_column = 'X'.
wa_fieldcat-outputlen = 18.
wa_fieldcat-tooltip = text-007.
APPEND wa_fieldcat TO i_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-row_pos = 0.
wa_fieldcat-col_pos = 2.
wa_fieldcat-fieldname = 'WERKS'.
wa_fieldcat-scrtext_l = text-008.
wa_fieldcat-scrtext_m = text-008.
wa_fieldcat-scrtext_s = text-008.
wa_fieldcat-fix_column = 'X'.
wa_fieldcat-outputlen = 4.
wa_fieldcat-tooltip = text-008.
APPEND wa_fieldcat TO i_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-row_pos = 0.
wa_fieldcat-col_pos = 3.
wa_fieldcat-fieldname = 'MAKTX'.
wa_fieldcat-scrtext_l = text-009.
wa_fieldcat-scrtext_m = text-010.
wa_fieldcat-scrtext_s = text-011.
wa_fieldcat-tooltip = text-009.
wa_fieldcat-outputlen = 40.
APPEND wa_fieldcat TO i_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-row_pos = 0.
wa_fieldcat-col_pos = 4.
wa_fieldcat-fieldname = 'MEINS'.
wa_fieldcat-scrtext_l = text-012.
wa_fieldcat-scrtext_m = text-013.
wa_fieldcat-scrtext_s = text-014.
wa_fieldcat-outputlen = 4.
wa_fieldcat-tooltip = text-012.
APPEND wa_fieldcat TO i_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-row_pos = 0.
wa_fieldcat-col_pos = 5.
wa_fieldcat-fieldname = 'MTART'.
wa_fieldcat-scrtext_l = text-015.
wa_fieldcat-scrtext_m = text-015.
wa_fieldcat-scrtext_s = text-016.
wa_fieldcat-tooltip = text-015.
APPEND wa_fieldcat TO i_fieldcat.
CLEAR wa_fieldcat.
ENDAT.
v_year = wa_week-week+0(4).
v_week = wa_week-week+4(2).
CONCATENATE v_week k_slash v_year INTO l_v_colname.
wa_fieldcat-row_pos = 0.
wa_fieldcat-col_pos = 6 + sy-index.
wa_fieldcat-fieldname = wa_week-week.
wa_fieldcat-quantity = 'X'.
wa_fieldcat-outputlen = 18.
wa_fieldcat-scrtext_l = l_v_colname.
wa_fieldcat-tooltip = l_v_colname.
APPEND wa_fieldcat TO i_fieldcat.
CLEAR : wa_fieldcat,
l_v_colname,
wa_week.
ENDLOOP.
ENDFORM. " populate_fieldcat
*& Form fill_table
text
--> p1 text
<-- p2 text
FORM fill_table .
**--Create Work Area Dynamically
CREATE DATA wa_gp_line LIKE LINE OF <gt_table>.
ASSIGN wa_gp_line->* TO <gwa_table>.
DATA : l_v_col TYPE char25,
l_v_val TYPE char25.
LOOP AT i_final INTO wa_final.
l_v_col = wa_final-week.
ASSIGN COMPONENT l_v_col OF STRUCTURE <gwa_table>
TO <l_field>.
IF <l_field> IS ASSIGNED.
l_v_val = wa_final-mng01.
CONDENSE l_v_val.
<l_field> = l_v_val.
clear : l_v_val,
l_v_col.
ENDIF.
AT END OF matnr.
READ TABLE i_final INTO wa_final WITH KEY matnr = wa_final-matnr
BINARY SEARCH.
IF sy-subrc = 0.
ASSIGN COMPONENT 'MATNR' OF STRUCTURE <gwa_table>
TO <l_matnr>.
IF <l_matnr> IS ASSIGNED.
<l_matnr> = wa_final-matnr.
ENDIF.
ASSIGN COMPONENT 'WERKS' OF STRUCTURE <gwa_table>
TO <l_werks>.
IF <l_werks> IS ASSIGNED.
<l_werks> = wa_final-werks.
ENDIF.
ASSIGN COMPONENT 'MAKTX' OF STRUCTURE <gwa_table>
TO <l_maktx>.
IF <l_maktx> IS ASSIGNED.
<l_maktx> = wa_final-maktx.
ENDIF.
ASSIGN COMPONENT 'MEINS' OF STRUCTURE <gwa_table>
TO <l_meins>.
IF <l_meins> IS ASSIGNED.
<l_meins> = wa_final-meins.
ENDIF.
ASSIGN COMPONENT 'MTART' OF STRUCTURE <gwa_table>
TO <l_mtart>.
IF <l_mtart> IS ASSIGNED.
<l_mtart> = wa_final-mtart.
ENDIF.
APPEND <gwa_table> TO <gt_table>.
CLEAR <gwa_table>.
ENDIF.
ENDAT.
ENDLOOP.
ENDFORM. " fill_table
*& Module STATUS_0100 OUTPUT
text
MODULE status_0100 OUTPUT.
SET PF-STATUS 'ZMUNNA'.
SET TITLEBAR 'MRP'.
IF v_custom_container IS INITIAL.
CREATE OBJECT v_custom_container
EXPORTING
container_name = v_container.
CREATE OBJECT v_grid
EXPORTING
i_parent = v_custom_container.
CALL METHOD v_grid->set_table_for_first_display
CHANGING
it_outtab = <gt_table>
it_fieldcatalog = i_fieldcat.
ENDIF.
ENDMODULE. " STATUS_0100 OUTPUT
*& Module USER_COMMAND_0100 INPUT
text
MODULE user_command_0100 INPUT.
v_ok_code = sy-ucomm.
CLEAR sy-ucomm.
CASE v_ok_code.
WHEN 'EXIT'.
PERFORM exit_program.
SET SCREEN 000.
ENDCASE.
ENDMODULE. " USER_COMMAND_0100 INPUT
*& Form exit_program
text
--> p1 text
<-- p2 text
FORM exit_program .
CALL METHOD v_custom_container->free.
CALL METHOD cl_gui_cfw=>flush.
ENDFORM. " exit_program
Reward points if that helps.
Manish
Similar Messages
-
Dynamic Structures and Internal Tables
Hi All,
I am doing a report to create condition records based on the condition type and condition table. Assume the condition type as PR00 and it as condition table of 304,305,306.Each condition table as its own header and item fields.Based on the condition table that the user specifies in the selection screen
the header and item structures of my report should change dynamically and these should be moved to the dynamic internal table that contains both header and item fields.Can anyone give an idea how to achieve it. Thanks in advance.
Regards,
Chakradhar.Hi All,
Thanks for your replies.
SPLIT i_string_line-input_str AT cl_abap_char_utilities=>horizontal_tab
INTO i_header_line-header
i_header_line-vkorg
i_header_line-vtweg
i_header_line-pltyp
i_header_line-waerk.
In the above syntax based on the condition table I selected on selection screen my flat file is as below.
case 1: If condition table given is 304
H SalesOrganization DistributionChannel Customer
I Material Releasestatus Amount Currency ValidFrom ValidTo
case 2: If condition table given is 305
H SalesOrganization DistributionChannel
I Material Releasestatus Amount Currency ValidFrom ValidTo
case 3: If condition table given is 306
H SalesOrganization DistributionChannel PriceListType DocumentCurrency
I Material Releasestatus Amount Currency ValidFrom ValidTo
In the above code i_string_line-input_str contains the following heading of fields based on the condition table we select in selection screen.when I want to split them into respective fields
using INTO clause my structure should change dynamically.How can I achieve it and my entire program is in OOPS ALV.Thanks in Advance.
Regards,
Chakradhar. -
Dynamic creation of internal table based on alv layout
Hi experts!!
I have the following request from my client:
I am displaying an alv report and i need to download it in txt format based on the columns showed in the current layout (i.e. if the user chooses to hide some columns, then they should not appear in the txt file ). In the alv i am using the Function Modules of the alv and not ABAP Objects.
I thought of dynamically creating the internal table, but i am not sure how to do it.
I also thaught of creating an internal table with only one field with the maximum length, but how can i check which fields are diplayed, and how can i get their values??
Please Help!!
Thank u in advance!!!
Please - no duplicate posts
Edited by: Rob Burbank on Feb 24, 2009 2:16 PMAfter call the above said function module you will get the exporting table for field catalog ie
call function 'REUSE_ALV_GRID_LAYOUT_INFO_GET'
importing
es_layout = ls_slis_layo
et_fieldcat = lt_slis_fcat
if you check the lt_slis_fcat internal table if the field are hide in the layout by the user then in this internal table check for field NO_OUT will X.
Take the fields where NO_OUT ne X
then for creating dynamic internal table
field-symbols : <ptab> type standard table.
call method cl_alv_table_create=>create_dynamic_table
exporting
it_fieldcatalog = lt_slis_fcat
importing
ep_table = i_content.
if sy-subrc = 0.
assign i_content->* to <ptab>.
else.
write: 'Error creating internal table'.
stop.
endif.
Here is the dynamic internal table
a® -
Dynamicly creating an internal table with header line
Hi experts,
I am trying to do a read on an internal table using field symbols of type any table. To be able to read more than one row at once, I'd like to read it into another internal table (instead of just one line and instead of looping through them one by one).
So far the following line rendered an error that the target internal table doesn't have a header line
read table <fs_v_tab> WITH KEY (<fs_comp>) = <fs_param>-low INTO <fs_v_tab>.
(also attempted using "<fs_v_tab>->*" & "<fs_v_tab>[]" to be silly)
Based on the following article, I was wondering if it were possible to dynamicly create an internal table with header line.
[http://help-abap.blogspot.com/2008/09/dynamic-internal-table-creation.html|http://help-abap.blogspot.com/2008/09/dynamic-internal-table-creation.html]
Any help or tips on how to dynamicly filter an internal table field-symbol is greatly appreciated!Just read the online help:
This statement reads a row from internal table itab.
Or more exact:
This statement reads one row from internal table itab.
Therefore you can not read multiple lines into another table. The header line is needed to put the result in. And this is not what you intended, the result will be in the header line, not in the table itself.
If the row to be read is not uniquely specified, the first suitable row is read. In the case of index tables, this row has the lowest table index of all matching rows.
At least you have to do what you dont wanna do: looping. -
SAP QUERY LOOPS AND INTERNAL TABLE
Hi All, I have a query which i have made. It runs from Table EKPO which has PO details and what I want to do is now via ABAP Code pull through the total of goods receipt for the PO and Line Item into a field. Sounds Easy enough..Problem now,
The table which contains the GR data is EKBE which agains a PO and Line Item can have many 101 movements and 102 movements so what I want is an ABAP Statent to basically sum up the total of 101 for the PO & LINE ITEMS and then minus this from the total of 102 for the PO & LINE ITEMS and post the result in to this new field I have created.
I am pretty decent with ABAP Code in Querys I.e Select statements etc but from what I can see i need to create an internal table and do a loop and collect statement but I keep on failing due to not enough knowledge. Please can some one help me with this and provide me with the code and explanation as i would like to understand,
POINTS WILL BE REWARDED
Thanks
Kind Regards
Adeel SarwarHi,
This is the full code i have entered but its not working. Any help would be appreciated. If you could rectify the code and internal tables that would be great.
Thanks
TABLES: EKBE.
DATA: PurO LIKE EKPO-EBELN,
POLI LIKE EKPO-EBELP.
*New Table and Vars defined
DATA: BEGIN OF IT_EKBE,
IT_EKBE LIKE EKBE,
END OF IT_EKBE.
DATA: BEGIN OF IT_SUM OCCURS 0,
EBELN TYPE EBELN,
EBELP TYPE EBELP,
DMBTR TYPE DMBTR,
MENGE TYPE MENGE,
END OF IT_SUM.
CLEAR: QTYD.
MOVE: EKPO-EBELN TO PurO,
EKPO-EBELP TO POLI.
SELECT * FROM EKBE INTO IT_EKBE
WHERE EBELN = PurO
AND EBELP = POLI
AND BEWTP = 'E'
LOOP AT IT_EKBE.
MOVE CORRESPOING IT_EKBE TO IT_SUM.
IF IT_EKBE-BWART = '102'.
IT_SUM-DMBTR = IT_SUM-DMBTR * -1.
IT_SUM-MENGE = IT_SUM-MENGE * -1.
ENIDF.
COLLECT IT_SUM.
CLEAR IT_SUM.
ENDLOOP.
ENDSELECT.
If sy-subrc = 0.
QTYD = IT_SUM.
ELSE.
QTYD = 0.
ENDIF. -
Export - Import In ABAP ( for variables and internal table)
how can we pass value for the variable and internal table using Export and Import?
data: var type sy-uzeit.
var = sy-uzeit.
EXPORT var TO MEMORY ID 'TIME'.
data: var type sy-uzeit.
IMPORT var FROM MEMORY ID 'TIME'.
write:/ var,sy-subrc,sy-uzeit.
i found var value 0 while importing.
what is the right syntax for passing value of variable and internaltable.
regards,
dushyant.Hi,
There are two possible solutions.
Solution1:
Program1.Should be run before atleast once so that TIME should be filled.
data: var type sy-uzeit.
var = sy-uzeit.
EXPORT var TO MEMORY ID 'TIME'.
Program2.IF the TIME is filled,then only it will produce the result.
data: var type sy-uzeit.
clear var.
IMPORT var FROM MEMORY ID 'TIME'.
write:/ var, sy-subrc, sy-uzeit.
Solution2:
Single program:
data: var type sy-uzeit.
var = sy-uzeit.
EXPORT var TO MEMORY ID 'TIME'.
clear var.
IMPORT var FROM MEMORY ID 'TIME'.
write:/ var, sy-subrc, sy-uzeit.
Kindly reward points by clikcing the star on the left of reply,if it helps. -
DIFF: Field string ,Structure and Internal table declaration
Hai,
what is the diference between Field string ,Structure in ABAP program and Internal table declaration and how it will work ?
Thank you
ASHOK KUMAR.hi,
Look this u will get a good idea.
*& Report ZTYPES *
REPORT ZTYPES .
* Table declaration (old method)
DATA: BEGIN OF tab_ekpo OCCURS 0, "itab with header line
ebeln TYPE ekpo-ebeln,
ebelp TYPE ekpo-ebelp,
END OF tab_ekpo.
*Table declaration (new method) "USE THIS WAY!!!
TYPES: BEGIN OF t_ekpo,
ebeln TYPE ekpo-ebeln,
ebelp TYPE ekpo-ebelp,
END OF t_ekpo.
DATA: it_ekpo TYPE STANDARD TABLE OF t_ekpo INITIAL SIZE 0, "itab
wa_ekpo TYPE t_ekpo. "work area (header line)
* Build internal table and work area from existing internal table
DATA: it_datatab LIKE tab_ekpo OCCURS 0, "old method
wa_datatab LIKE LINE OF tab_ekpo.
* Build internal table and work area from existing internal table,
* adding additional fields
TYPES: BEGIN OF t_repdata.
INCLUDE STRUCTURE tab_ekpo. "could include EKKO table itself!!
TYPES: bukrs TYPE ekpo-werks,
bstyp TYPE ekpo-bukrs.
TYPES: END OF t_repdata.
DATA: it_repdata TYPE STANDARD TABLE OF t_repdata INITIAL SIZE 0, "itab
wa_repdata TYPE t_repdata. "work area (header line)
Regards
Reshma -
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 -
Difference between line type and internal table?
Hi..
I wanted to know, what is the difference between Line type and Internal Table?Hi,
Before the 4.7 release in SAP if we want to define an internal table we have to write the defination using the occurs statement and we need to define all the fields using INCLUDE STRUCTURE or indidually all the fields ine by one.
From 4.7 release of R/3 SAP introduced the Line type concept and it's part of the ABAP OOPS concept. for internal table defination we don't need to use the occur statements. Instead INCLUDE structure we need to create a Line type for that structure in Se11 and then we can define the internal table like :
DATA : ITAB TYPE TABLE OF <LINE_TYPE>.
Only thing is this table will be a table without header. So for internal table processing we need to define a work area structure of type line of line type . EX:
DATA: WA_ITAB TYPE LINE OF <LINE_TYPE>.
Hope this helps.
Thanks,
Greetson -
DATA BASE TABLE AND INTERNAL TABLE
Dear Friends,
please help me out in getting complete information about database table and internal table.
you can email me at < Removed by moderator - please maintain e-mail iDs in Business Card>
Message was edited by:
Arun VaradarajanHi Hazi,
<b>DATABASE Tables :</b>
This are the tables which are stored in the database (eg Oracle , informix , DB2 etc..) Physically. u can view it from T-codes SE11 or SE16. here in SE11 u can create ur own Transparent table.
for more information...
http://www.sapbrainsonline.com/TUTORIALS/TECHNICAL/dictionary_tutorial.html
<b>Internal Tables.</b>
While generating reports or other objects we are not modifying the database tables directly first we are selecting the data of the database table into the internal tables... so that we can reduce the database access time and network traffic .. which is highly needed in R/3 system..
internal tables are not exist phyiscally in the system. its like a array. the existance of the internal tables is upto the program execution in which u r declaring nd using it...
for more information..
http://www.sapbrainsonline.com/TUTORIALS/TECHNICAL/internaltables_tutorial.html
Hope it will solve ur problem..
<b>Reward points if useful..</b>
Thanks & Regards
ilesh 24x7 -
Table types and internal table
Hi all,
What is the relationship between table type in ABAP dictionary and internal table?
Moderator message : Search for available information OR read ABAP documentation. Thread locked.
Edited by: Vinod Kumar on Jul 16, 2011 11:16 AMYou can INCLUDE TYPE.
Types: begin of itab,
field1 type string,
field2 type string,
* More Fields in here.
Field30 type string,
End of itab.
Data: lt_itab type table of itab.
TYPES BEGIN OF new_itab.
INCLUDE type itab.
TYPES: field31 type string,
field32 type string,
END OF new_itab.
Regards,
Rich Heilman -
Passing SELECT-OPTIONS and Internal Tables to SUBROUTINES
Hi Guys
In the code below my colleague has created her own table types in order to pass a select option and internal tables to her subroutine. Is there an easier way of making them known to the subroutine.
data : v_vbeln type vbeln_vf,
it_bdoc type table of vbrp,
it_t006 type table of t006a,
wa_bdoc type vbrp,
wa_t006 type t006a,
it_bdoc2 type table of zsswathi_st_vbeln,
wa_bdoc2 type zsswathi_st_vbeln
select-options s_vbeln for v_vbeln matchcode object zswathi_vbeln obligatory.
start-of-selection.
perform bdoc using s_vbeln[]
changing it_bdoc
it_bdoc2
it_t006.
loop at it_bdoc2 into wa_bdoc2.
form bdoc using f_s_vbeln type ZSWATHI_ST_SELECT_OPTION_TA_TY " all these are table types. for select options, a structure is created and then a table type for it is created.
changing f_it_bdoc type zswathi_vbrp_ty_ta
f_it_bdoc2 type zswathi_vbeln_ty_ta
f_it_t006 type ZSWATHI_T006_TA_TY.
select * from vbrp into table f_it_bdoc where vbeln in f_s_vbeln.
if f_it_bdoc is not initial.
select vbeln sum( netwr ) prsdt from vbrp into table f_it_bdoc2 where vbeln in f_s_vbeln group by vbeln prsdt.
sort f_it_bdoc2 by vbeln.
"select * from t006a into table it_t006 for all entries in it_bdoc where msehi = it_bdoc-vrkme.
select * from t006a into table f_it_t006 for all entries in f_it_bdoc where msehi = f_it_bdoc-vrkme.
endif.
endform.Hi Brett,
1. you can use a select-options-range in a FORM subroutine also without passing it as a parameter because parameters and select-option range tables are global fields in their program.
2. If you need a parameter, declare it as type table or type standard table or type any table. You do not need any special table type.
Regards
Clemens -
How do we pass values and Internal tables to Sub-routines
how do we pass values and Internal tables to Sub-routines
Hi,
You can use the USING..or TABLES..or Changing addition..
Check this example.
DATA: T_MARA TYPE STANDARD TABLE OF MARA.
PERFORM DISPLAY USING T_MARA.
FORM DISPLAY USING LT_MARA LIKE T_MARA.
DATA: WA TYPE MARA.
LOOP AT LT_MARA INTO WA.
WRITE: / WA-MATNR.
ENDLOOP.
ENDFORM.
Thanks
Naren -
Difference between work area and internal tables.
Hi I wanna know the difference between work area and internal tables.
what happend if i give with out header line in internal table.
also how to assosiate work area to internal table in that scenario.Hi Balaji..
The internal table is an ABAP runtime object which has two parts the Body and the header.
Whereas a work area cannot have a body.. It is mere a field or group of fields which can hold values at runtime..
In the SAP higher versions mySAP ERP, the use of tables with header line is made obsolete.. But there is absolutely no problem with the same..
Just think that when you define an internal table with occurs or with header line statement, the system automatically creates a workarea with this table, using which you can access the contents in the bosy of tyhe table.. You can read a record from the table body to this header or add a record in the header to the internal table body..
When you work with a table ITAB without a header line, you can not use statements like READ TABLE, APPEND, INSERT etc without giving an explicit work area..
Suppose i have an internal table like:
DATA : itab TYPE STANDARD TABLE OF t001.
This table will not have a header with it.
If you will use APPEND itab. The compilor will give error.
Here i will create a work area with same structure of the table.
DATA : e_wa TYPE t001.
Now i will write:
APPEND e_wa TO itab.
READ TABLE itab INTO e_wa WITH KEY xxxxxx
LOOP AT itab INTO e_wa... etc..
In a better approach we use Field symbols with such tables, instead of structures
FIELD-SYMBOLS: <fs_itab> TYPE t001.
So,
LOOP AT itab ASSIGNING <fs_itab>
READ TABLE itab ASSIGNING <fs_itab> etc.. However we can not use field symbols in few cases..
I hope this will help you..
Thanks and Best Regards,
Vikas Bittera.
**Points for usefull answers** -
ALV grid refresh while fcat and internal table change
Hi,
I am displaying an ALV output using OOPS ALV grid. It is displaying data from internal table t1.
Later I am changing fieldcat table content and I want to display with internal table t2. how can I do this.
It is not refreshing the fieldcat values in the ALV.
Which method I should call to refresh the ALV.
Thanks and regards,
Venkat.hi,
to refresh the alv display.
you can use the method refresh_table_display
of the class cl_gui_alv_grid.
regards.
Maybe you are looking for
-
App Store is not working and flicking on Pro
Hi All, I am new to this and hoping you can help me. I launched the App store and this message comes up. Then when i click continue it starts flickering like mad. I cannot upgrade anything mac related now that this has happened. I hope you can help m
-
Material master error in sales order??/
Hi SAP gurus While creating sales order after copying the standard material from IDES its giving a error message ""material not determined for sales organization 1000, dist ch 10,language DE"" PLz provide the solution for the same
-
Stored procedure by a JDBC sender
Hi, My scenario involves accessing an SQL server to XI to APO. I need to invoke a stored procedure residing on SQL server in order to get the data into XI. Can somebody suggest how i acheive this. It has to be done every month...so is there a way i c
-
Controlling Acrobat functionality through servlet download.
Hi, I'm pushing a PDF through the ServletOutputStream so that it is displayed at the PC. The code (after I've got a ByteArrayInputStream with the PDF) is as follows: response.setContentType("application/pdf"); response.setContentLength(bais.available
-
Java outputstream java.lang.OutOfMemoryError: Java heap space
Hi All, I am trying to publish a large video/image file from the local file system to an http path, but I run into an out of memory error after some time... here is the code public boolean publishFile(URI publishTo, String localPath) throws Exception