Internal Table Operation Help Required
Hi
I have to insert 8 counters p1-p8 in a field BANFN of ITAB1.
Like this their are 3 more fileds.I have to show the no. for PR released frm JAN-DEC in ALV format.I had doen the calualation,but unable to insert these conters in ITAB1 to do final calculation & display the result.
Please help me.
I had used : insert p1 into itab1-banfn where sy-index 1.
Like this I had tried out many comands,but al in vain.PLZ help me in this regard.
Regards.
Vipin
There are 8 fileds in my internal table,in which 1st one is for MONTH(JAN-DEC).
The ALV is only suppose to display 12 rows,containing each month per row.
Now for each month I have to display the PR converted to PO & the avg lead time for each month.So I had calu all the data ,but now I have to insert 12 counters in 4 fields.one for No of PR converted to PO in each month,than one for AVG LEAD TIME for each month.so there has to be 12 + 12 counters for each row.Similar operation I have to perform for the PR pending fo PO.So there has to be 24 more counters for again 2 diff fileds.Now I had calcuated the data,but the problem is this ,,,,,how to insert each ctr in each row.
EG: insert ctr1 into itab1-banfn where itab1-mmyy = 'January' or sy-index = 1.
insert ctr2 into itab1-banfn where itab1-mmyy = 'Febuary' or sy-index = 2.
move crt1 to itab1-banfn where sy-index = 1.
None of the operation is working.
Like this i have to insert 48 counters in all rows for these 4 diff fileds.
Pl help me in thsi regard ,if possible.
regards.
Similar Messages
-
Internal table logic - help required
Hi,
I am working on BSEG table to determine offsetting line count and amount total for a posting line item and need
a small logic .
I have a table of currency fields like below and the table is such ( like BSEG ) that each line item will balance
itself with other line item . For example
Item
10 100
20 100-
30 200
40 250
50 450-
60 200-
70 200
80 600
90 100
100 200
110 300
If you see 10 & 20 balance out similarly ( 30,40 will balance with line item 50 ) , ( 60 & 70 balance each other ) ,
( 90,100, 110 balance with 80 ).
My requirement - If I loop on item 50 with amount 450- I need to get the posnr of the two items which balance
this amount ( which is 30 and 40 ). If I loop on item 80 with amount 600 then I need to get item 90. 100 and 110.
Please provide me a logic which will provide me the index of ther required item lines.
Regards
PraneethHi, execute this code.. might be helpful to you
TYPES: BEGIN OF test,
a TYPE i,
b TYPE i,
END OF test.
DATA: itab TYPE TABLE OF test,
wa TYPE test,
wa1 TYPE test,
c TYPE i,
d TYPE i,
n1 TYPE i,
n2 TYPE i.
PARAMETERS : p TYPE i.
wa-a = 1.
wa-b = 20.
APPEND wa TO itab.
wa-a = 2.
wa-b = 30.
APPEND wa TO itab.
wa-a = 3.
wa-b = 10.
APPEND wa TO itab.
wa-a = 4.
wa-b = 10.
APPEND wa TO itab.
wa-a = 5.
wa-b = 20.
APPEND wa TO itab.
READ TABLE itab INTO wa WITH KEY a = p.
c = wa-b.
LOOP AT itab INTO wa WHERE a GT p.
n1 = wa-a.
IF c EQ wa-b.
EXIT.
ENDIF.
LOOP AT itab INTO wa1 WHERE a GT wa-a.
IF wa-a = wa1-a.
EXIT.
ENDIF.
n2 = wa1-a.
d = wa-b + wa1-b.
IF c EQ d.
EXIT.
ENDIF.
ENDLOOP.
IF wa-a = wa1-a.
EXIT.
ELSEIF c EQ d.
EXIT.
ELSE.
CLEAR: n1, n2.
ENDIF.
ENDLOOP.
WRITE: n1 , n2. -
Error on extend an internal table, but the required space was not available
Hi All,
I am trying to retrieve cost data from COVP tables, as well as the quantity, cost centre, and price unit fields from MSEG / BSEG tables. Thing is, if the AWTYP value in COVP table = 'MKPF', i have to get the data from MSEG, otherwise, I need to get it from BSEG table.
I kept getting this error message:
<i>You attempted to extend an internal table, but the required space was not available.</i>
Anyone have any idea how to make my codes more efficient?
Please help. Thanks!
Regards,
Cecilia
REPORT ZMISCY004.
TABLES : COVP, BSIS, BSEG, MSEG, MAKT, CSKU.
PARAMETERS :
P_FILE(300) DEFAULT '\sapdcdatasaprptoh.txt' LOWER CASE.
DATA MSG_TEXT(50).
DATA :
XKOKRS LIKE COVP-KOKRS,
XBELNR LIKE COVP-BELNR,
XBUZEI LIKE COVP-BUZEI,
XGJAHR LIKE COVP-GJAHR,
XPERIO LIKE COVP-PERIO,
XWKGBTR LIKE COVP-WKGBTR,
XWTGBTR LIKE COVP-WTGBTR,
XREFBN LIKE COVP-REFBN,
XREFBZ LIKE COVP-REFBZ,
XKSTAR LIKE COVP-KSTAR,
XBEKNZ LIKE COVP-BEKNZ,
XMATNR LIKE COVP-MATNR,
XBUKRS LIKE COVP-BUKRS,
XREFGJ LIKE COVP-REFGJ,
XREFBK LIKE COVP-REFBK,
XLTEXT LIKE CSKU-LTEXT,
XMAKTX LIKE MAKT-MAKTX,
XAWTYP LIKE COVP-AWTYP,
XTWAER LIKE COVP-TWAER,
XSGTXT LIKE COVP-SGTXT,
BSEG_KOSTL LIKE BSEG-KOSTL,
BSEG_MEINS LIKE BSEG-MEINS,
BSEG_MENGE LIKE BSEG-MENGE,
MSEG_KOSTL LIKE MSEG-KOSTL,
MSEG_MENGE LIKE MSEG-MENGE,
MSEG_MEINS LIKE MSEG-MEINS.
DATA : BEGIN OF ITAB_COVP OCCURS 10,
KOKRS LIKE COVP-KOKRS,
BELNR LIKE COVP-BELNR,
BUZEI LIKE COVP-BUZEI,
GJAHR LIKE COVP-GJAHR,
PERIO LIKE COVP-PERIO,
WKGBTR(15) TYPE C,
WTGBTR(15) TYPE C,
REFBN LIKE COVP-REFBN,
REFBZ(3) TYPE C,
KSTAR LIKE COVP-KSTAR,
BEKNZ LIKE COVP-BEKNZ,
MATNR LIKE COVP-MATNR,
BUKRS LIKE COVP-BUKRS,
REFGJ LIKE COVP-REFGJ,
REFBK LIKE COVP-REFBK,
LTEXT LIKE CSKU-LTEXT,
MAKTX LIKE MAKT-MAKTX,
AWTYP LIKE COVP-AWTYP,
TWAER LIKE COVP-TWAER,
SGTXT LIKE COVP-SGTXT,
BSIS_WRBTR(13) TYPE C,
BSEG_KOSTL LIKE BSEG-KOSTL,
BSEG_MEINS LIKE BSEG-MEINS,
BSEG_MENGE LIKE BSEG-MENGE,
MSEG_KOSTL LIKE MSEG-KOSTL,
MSEG_MENGE LIKE MSEG-MENGE,
MSEG_MEINS LIKE MSEG-MEINS.
DATA : END OF ITAB_COVP.
SELECT M1~KOKRS
M1~BELNR
M1~BUZEI
M1~GJAHR
M1~PERIO
M1~WKGBTR
M1~WTGBTR
M1~REFBN
M1~REFBZ
M1~KSTAR
M1~BEKNZ
M1~MATNR
M1~BUKRS
M1~REFGJ
M1~REFBK
M1~AWTYP
M1~TWAER
M1~SGTXT
M4~KOSTL
M4~MENGE
M4~MEINS
INTO (XKOKRS,
XBELNR,
XBUZEI,
XGJAHR,
XPERIO,
XWKGBTR,
XWTGBTR,
XREFBN,
XREFBZ,
XKSTAR,
XBEKNZ,
XMATNR,
XBUKRS,
XREFGJ,
XREFBK,
XAWTYP,
XTWAER,
XSGTXT,
MSEG_KOSTL,
MSEG_MENGE,
MSEG_MEINS
FROM COVP AS M1
LEFT OUTER JOIN MSEG AS M4
ON M1~REFBN = M4~MBLNR AND M1~REFBZ = M4~ZEILE AND M1~REFGJ = M4~MJAHR
WHERE M1~SCOPE = 'OCOST' AND M1~AWTYP = 'BKPF'
OR M1~SCOPE = 'OCOST' AND M1~AWTYP = 'MKPF'
OR M1~KSTAR = '972022'.
IF XAWTYP = 'BKPF'.
SELECT KOSTL MENGE MEINS INTO (BSEG_KOSTL, BSEG_MENGE, BSEG_MEINS) FROM
BSEG WHERE BELNR = XREFBN AND BUZEI = XREFBZ AND GJAHR = XREFGJ AND
BUKRS = XREFBK.
ENDSELECT.
MOVE BSEG-KOSTL TO BSEG_KOSTL.
MOVE BSEG-MEINS TO BSEG_MEINS.
MOVE BSEG-MENGE TO BSEG_MENGE.
ELSE.
MOVE ' ' TO BSEG_KOSTL.
MOVE ' ' TO BSEG_MEINS.
MOVE ' ' TO BSEG_MENGE.
ENDIF.
*GET LTEST
SELECT LTEXT INTO XLTEXT
FROM CSKU
WHERE KTOPL = 'COAA' AND SPRAS = 'EN'.
*GET MAKTX
IF XMATNR <> ' '.
SELECT SINGLE * FROM MAKT WHERE MATNR = XMATNR.
MOVE MAKT-MAKTX TO XMAKTX.
ELSE.
MOVE ' ' TO XMAKTX.
ENDIF.
MOVE : XKOKRS TO ITAB_COVP-KOKRS,
XBELNR TO ITAB_COVP-BELNR,
XBUZEI TO ITAB_COVP-BUZEI,
XGJAHR TO ITAB_COVP-GJAHR,
XPERIO TO ITAB_COVP-PERIO,
XWKGBTR TO ITAB_COVP-WKGBTR,
XWTGBTR TO ITAB_COVP-WTGBTR,
XREFBN TO ITAB_COVP-REFBN,
XREFBZ TO ITAB_COVP-REFBZ,
XKSTAR TO ITAB_COVP-KSTAR,
XBEKNZ TO ITAB_COVP-BEKNZ,
XMATNR TO ITAB_COVP-MATNR,
XBUKRS TO ITAB_COVP-BUKRS,
XREFGJ TO ITAB_COVP-REFGJ,
XREFBK TO ITAB_COVP-REFBK,
XLTEXT TO ITAB_COVP-LTEXT,
XMAKTX TO ITAB_COVP-MAKTX,
XAWTYP TO ITAB_COVP-AWTYP,
XTWAER TO ITAB_COVP-TWAER,
XSGTXT TO ITAB_COVP-SGTXT,
BSEG_KOSTL TO ITAB_COVP-BSEG_KOSTL,
BSEG_MEINS TO ITAB_COVP-BSEG_MEINS,
BSEG_MENGE TO ITAB_COVP-BSEG_MENGE,
MSEG_KOSTL TO ITAB_COVP-MSEG_KOSTL,
MSEG_MENGE TO ITAB_COVP-MSEG_MENGE,
MSEG_MEINS TO ITAB_COVP-MSEG_MEINS.
APPEND ITAB_COVP.
CLEAR ITAB_COVP.
ENDSELECT.
ENDSELECT.
OPEN DATASET P_FILE FOR OUTPUT IN TEXT MODE.
IF SY-SUBRC NE 0.
WRITE: 'File cannot be opened. Reason:', MSG_TEXT.
EXIT.
ENDIF.
LOOP AT ITAB_COVP.
TRANSFER ITAB_COVP TO P_FILE.
ENDLOOP.
CLOSE DATASET P_FILE.Cecilia - I think your problemn is a nested select:
*GET LTEST
SELECT ltext INTO xltext
FROM csku
WHERE ktopl = 'COAA' AND spras = 'EN'.
*GET MAKTX
IF xmatnr <> ' '.
SELECT SINGLE * FROM makt WHERE matnr = xmatnr.
MOVE makt-maktx TO xmaktx.
ELSE.
MOVE ' ' TO xmaktx.
ENDIF.
MOVE : xkokrs TO itab_covp-kokrs,
etc.
mseg_meins TO itab_covp-mseg_meins.
APPEND itab_covp.
CLEAR itab_covp.
ENDSELECT.
Do you need to do the inner select for every cost element text?
Rob -
Dynamic internal table operations
Hi,
I have an issue with dynamic internal table wherein I need to write a select statement with For All Entries on dynamic internal table and populating the record into another dynamic internal table.
I am trying with the code below but its not working.
SELECT (FLD)
FROM (T_TABLE)
INTO CORRESPONDING FIELDS OF TABLE <DYN1_TABL>
FOR ALL ENTRIES IN <DYN_TABL>
WHERE KEY_FNAME = <DYN_TABL>-KEY_FNAME.
FLD is the dynamic field.
T_TABLE is the dynamic database table.
DYN1_TABL is the dynamic internal table
DYN_TABL is the dynamic internal table
KEY_FNAME is the dynamic key field of T_TABLE.
Pls help me on this issue.
Response with code snippets will be appreciated.
Thanks in advance.Thanks for your reply Nikki but my issue is to reference a field in dynamic internal table to be used with 'For All Entries' satement.
like for static we use
For All Entries in Itab where <fieldname> = itab-<fieldname>
I was looking for the same statement for dynamic tables -
Convert Columns into Rows (internal tables) - Urgent Help Pleasse..
Hi friends i'm having a little problem and hope you can help me..Here's the situation.
I have an internal table like shown below
(Key) (Key) (Key) (Key)
PATH_ID | GROUP | LINE | ATRIBUTE | VALUE
ASLN2 1 1 Company_Code 5146
ASLN2 1 1 Account_Code 400405
ASLN2 1 1 Profit_Centre AA00N2
ASLN2 1 2 Company_Code 5146
ASLN2 1 2 Account_Code 400705
ASLN2 1 2 Profit_Centre AA00N2
ASLN3 1 1 Company_Code 5146
ASLN3 1 1 Account_Code 400405
ASLN3 1 1 Profit_Centre AA00N2
ASLN3 1 2 Company_Code 5146
ASLN3 1 2 Account_Code 400705
ASLN3 1 2 Profit_Centre AA00N2
and i want to convert this internal table to one like below
PATH_ID | GROUP | LINE | Company Code | Account Code | Profit Centre
ASLN2 1 1 5146 400405 AA00N2
ASLN2 1 2 5146 400705 AA00N2
ASLN3 1 1 5146 400405 AA00N2
ASLN3 1 2 5146 400705 AA00N2
but i'm a bit of stuck, all those key fields are making me confused...anyone have a marvelous ( ) idea of how to implement this transformation ?
best regards,
Ricardo MonteiroItab1 with the structure PATH_ID | GROUP | LINE | ATRIBUTE | VALUE
Itab2 with structure PATH_ID | GROUP | LINE | ATRIBUTE | VALUE
Itab3 with the final structure PATH_ID | GROUP | LINE | Company Code | Account Code | Profit Centre
move itab1 to itab2.
sort itab2 by path_id group line.
delete adjacent duplicates from itab2 comparing path_id group line.
loop at itab2.
clear itab3.
move:
itab2-pathid to itab3-pathid,
itab2-group to itab3-group,
itab2-line to itab3-line.
loop at itab1where pathid = itab2-pathid
and group = itab2-group
and line = itab2-line.
IF itab1-ATRIBUTE = ' Company_Code'.
itab3-Company_Code = itab1-attribute.
elseif itab1-ATRIBUTE = ' Account_Code '.
itab3-Account_Code = itab1-attribute.
elseif itab1-ATRIBUTE = ' Profit_Centre ' .
itab3-profit_center = itab1-attribute.
endif
endloop.
append itab3.
endloop.
try this.
Thanks,
rajinikanth -
hi,
I've a htmlb tableview which gets the data from an internal table which is a data member of a model. I've two column fields in this view which are editable. What are the steps I need to follow in order to get the internal table updated with the values provided by the user in the editable fields of tableview.
could someone please provide me with the steps as to how to achieve this?
Thanks and Regards,
VamshiHi Vamshi,
Try this sample code,as it helps you considerably.
local types
types: itabtype type TABLE OF STD1.
types: begin of message_struct,
type type char10,
text type char100,
end of message_struct.
page attributes
addtab TYPE ITABTYPE
addtab_row TYPE STD1
add_flag TYPE FLAG
deltab TYPE ITABTYE
deltab_row TYPE STD1
ITAB TYPE ITABTYPE
iterator TYPE REF TO IF_HTMLB_TABLEVIEW_ITERATOR
message TYPE MESSAGE_STRUCT
STUDENT TYPE STRING
STATUS TYPE STRING
<b>layout</b>
<htmlb:content design="design2003" >
<htmlb:page title="test1" >
<htmlb:form>
<htmlb:tableView id = "tv1"
visibleRowCount = "20"
onRowSelection = "MyEventRowSelection"
selectionMode = "lineEdit"
table = "<%= ITAB %>"
iterator = "<%=iterator %>" />
<htmlb:button id = "save"
text = "Save Changes"
onClick = "myEvent" />
eventhandler OnCreate
this handler is called once the page is first created (stateful mode)
it performs a once-off data initialization or object creation
SELECT * FROM STD1
INTO CORRESPONDING FIELDS OF TABLE itab.
CREATE OBJECT iterator TYPE STD1ITERATOR.
eventhandler OnInputProcessing
event handler for checking and processing user input and
for defining navigation
DATA: ITAB_WA type Line of itabtype.
DATA: event TYPE REF TO cl_htmlb_event.
event = cl_htmlb_manager=>get_event( runtime->server->request ).
FIELD-SYMBOLS: <row> type STD1.
DATA: tv TYPE REF TO cl_htmlb_tableview.
tv ?= cl_htmlb_manager=>get_data(
request = runtime->server->request
name = 'tableView'
id = 'tv1' ).
IF tv IS NOT INITIAL.
DATA: tv_data TYPE REF TO cl_htmlb_event_tableview.
tv_data = tv->data.
IF tv_data->prevselectedrowindex IS NOT INITIAL.
FIELD-SYMBOLS: <row> type LINE OF ITABTYPE .
READ TABLE ITAB INDEX tv_data->prevselectedrowindex
ASSIGNING <row>.
DATA value TYPE string.
if <row> is assigned.
value = tv_data->get_cell_id( row_index =
tv_data->prevselectedrowindex
column_index = '1' ).
DATA: inputfield TYPE REF TO cl_htmlb_inputfield.
inputfield ?= cl_htmlb_manager=>get_data(
request = request
name = 'inputfield'
id = value ).
<row>-STUDENT = inputfield->value.
value = tv_data->get_cell_id( row_index =
tv_data->prevselectedrowindex
column_index = '2' ).
inputfield ?= cl_htmlb_manager=>get_data(
request = request
name = 'inputfield'
id = value ).
<row>-STATUS = inputfield->value.
ENDIF.
ENDIF.
WHEN 'add'.
tv ?= cl_htmlb_manager=>get_data(
request = runtime->server->request
name = 'tableView'
id = 'tv1' ).
IF tv IS NOT INITIAL.
tv_data = tv->data.
IF tv_data->prevselectedrowindex IS NOT INITIAL.
READ TABLE itab INDEX tv_data->prevselectedrowindex
ASSIGNING <row>.
endif.
endif.
WHEN 'add'.
add_flag = 'Y'.
WHEN 'add_save'.
ITAB_WA-STATUS = request->get_form_field( 'STUDENT' ).
ITAB_WA-STATUS = request->get_form_field( 'STATUS' ).
endcase. -
Hi all,
Please tell me the alternative of using loop that is specified in Bold. some body saying that is an alternative of using some statement without using loop in loop.
* data declaration
DATA: BEGIN OF T1 OCCURS 0,
F1 TYPE I,
END OF T1.
DATA: BEGIN OF T2 OCCURS 0,
F1 TYPE I,
F2(10) TYPE C,
END OF T2.
DATA: T3 LIKE T2 OCCURS 0 WITH HEADER LINE.
* fill internal table T1
T1-F1 = 10.
APPEND T1.
T1-F1 = 20.
APPEND T1.
T1-F1 = 30.
APPEND T1.
T1-F1 = 40.
APPEND T1.
* fill internal table T2
T2-F1 = 10.
T2-F2 = 'AA'.
APPEND T2.
T2-F1 = 10.
T2-F2 = 'AB'.
APPEND T2.
T2-F1 = 10.
T2-F2 = 'AC'.
APPEND T2.
T2-F1 = 20.
T2-F2 = 'BA'.
APPEND T2.
T2-F1 = 20.
T2-F2 = 'BB'.
APPEND T2.
T2-F1 = 30.
T2-F2 = 'CA'.
APPEND T2.
T2-F1 = 30.
T2-F2 = 'CB'.
APPEND T2.
T2-F1 = 30.
T2-F2 = 'CC'.
APPEND T2.
T2-F1 = 40.
T2-F2 = 'DA'.
APPEND T2.
CLEAR: T1, T2.
* fill internal table T1
LOOP AT T1.
<b> LOOP AT T2 WHERE F1 = T1-F1.
APPEND T2 TO T3.
ENDLOOP.</b>
ENDLOOP.
* display internal table T1
LOOP AT T3.
WRITE:/ T3-F1, T3-F2.
ENDLOOP.HI
I guess for this case, there is no alternative statements as you have data in two internal tables. But
YES you can minimise during extraction via FOR ALL ENTRIES.
Eg:
tables: mara.
select-options: s_matnr for mara-matnr.
types: begin of t_mara,
matnr like mara-matnr,
mtart like mara-mtart,
end of t_mara.
types: begin of t_marc,
matnr like marc-matnr,
werks like marc-werks,
end of t_marc.
data: it_mara type standard table of t_mara,
it_marc type standard table of t_marc.
select matnr mtart into table it_mara
from mara
where matnr in s_matnr.
select matnr werks into table it_marc
from marc
for all entries in it_mara
where matnr = it_mara-matnr.
Kind Regards
Eswar -
Hi,
Right now I am working in table control.
I have an internal table that is getting displayed onto the table control,the internal table has the primary key MATNR in it.
When the user enters an identical MATNR in the second row the validation should throw a message that'Entry already exists' and the entry should get deleted.
The internal table is filled up from the database table using the WBS Element.Then before saving the new entry ,the database entry for the WBS element is deleted.
After updating the Internal table the internal table is inserted into the database table.
Can anyone let me know how to validate the new entry against the entries already existing in the internal table.
Hope i am able to make the problem clear to you.In the PAI Event write the code inside the CHAIN & ENDCHAIN.
PROCESS AFTER INPUT.
*pai flow logic for tablecontrol 'MPRN'
LOOP AT i_mprn.
CHAIN.
FIELD: i_mprn-select,
i_mprn-mprn,
i_mprn-post_code,
i_mprn-dm_ndm
MODULE validate_mprn.
ENDCHAIN.
MODULE tabctrl_modify.
ENDLOOP.
MODULE validate_mprn INPUT.
IF sy-ucomm EQ 'MPSB'.
PERFORM validate_mprn.
ENDIF.
ENDMODULE. " validate_mprn INPUT -
Problem with constraint in a table..help required..
Hi ,
i need to create a table which has an attribute year_joined and need to set a constraint that the year_joined should be less than or equal to the current year (year obtained from sysdate (YYYY)) ..
can any one help me with the create statement required...
eg: create table test(year_joined number, constraint c_year check(year_joined< = ?));
i could not use a sub query in the create statement.
help req..
thanks,
sriSatyaki,
I tried but fail. Could you please tell the way how it can be implementaed in CHECK constraint.
SQL> CREATE TABLE T ( YERR_JOINED NUMBER(4) , CHECK (YERR_JOINED <='2007'));
Table created.
SQL> drop table t;
Table dropped.
SQL> CREATE TABLE T ( YERR_JOINED NUMBER(4) , CHECK (YERR_JOINED <= TO_CHAR(SYSDATE,'YYYY')));
CREATE TABLE T ( YERR_JOINED NUMBER(4) , CHECK (YERR_JOINED <= TO_CHAR(SYSDATE,'YYYY')))
ERROR at line 1:
ORA-02436: date or system variable wrongly specified in CHECK constraint
SQL> -
Table Maintanance Help Required-urgent
Hi All,
I generating table maintanance generator for the table zuser_Secobjects. In this table GUID is a primary key and APPLN,APPLN_TYPE,PARTNER_TYPE are the non primary keys. I am using two screens method here. on both screens i am not showing GUID ( i am hiding this field in screen1 and screen 2) whenvere new record is created for every record guid is going to create. now my reuirement when i click on position(pushbutton) name in screen 1 it has to show APPLN,APPLN_TYPE,PARTNER_TYPE where as these 4 fields are non primary keys . i am getting uniqire record using guid. so i am keeping guid as primary key.i can't keep these 4 fields as primary keys in the table zuser_secobjects.
anybody can faced this kind of problem if so please let me know whow to approach in this case.
thanks,
maheedhar.tHai Maheedhar,
I have also faced the related problem.
<b>Please refer the below links.</b>
<b>It will helps you a lot.</b>
https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/abap/how%20to%20implement%20events%20in%20table%20maintenance.doc
Table Maintenance generator is required to do Manual entries in the Table. If the requirement is to update the table only programmatically and not manually then table maint. generator is not required.
Manual entries in table can be maintained ( New record can be inserted / existing can be modified ) using transaction SM 30, if the table maintenance for the table is generated.
<b>Don'forget to activate it.</b>
How to activate Table maint.
Goto SE11 and open the table.
Click UTILITIES -> Table Maint. Generator, Enter the details and click on Save. Then activate the table.
<b>Please refer the below links.</b>
https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/abap/how%20to%20implement%20events%20in%20table%20maintenance.doc
<b>Reward points if it helps you.</b>
Regds,
Rama chary.Pammi -
Live table insertion help required
I face issue of constraint violation the time when i try to insert record which already exist in table actually the table is getting populated on real basis and the record which i try to upload is around 2.5 million.
I need a PL/SQL code which perform insertion into live table and don't insert those records which already exists in live table.
I am new in PL/SQL and need your expert guidence
Please help
regards,In pl/sql you can trap oracle errors via an exception handler. For instance suppose you want to insert two rows, and the second row already exists (i.e. that row will get an oracle key-constraint error).
The way to deal with such an error in this case, would be to write a handler for the DUP_VAL_ON_INDEX error.
begin
begin
insert into some_table values(.. some values ..);
insert into some_table values(.. some other values ..);
exception when dup_val_on_index
then null;
end;
commit;
end;Above code will ignore the error for the second row, and will keep the first row inserted (and committed). -
Mutating table problem help required
Hi. I am rather hoping someone will be able to help me with this problem.
I have two tables, sa and mv. Create script below:
create table mv (
moduleId Char(2) CONSTRAINT ck_moduleId CHECK(moduleId in ('M1', 'M2', 'M3', 'M4', 'M5', 'M6', 'M7', 'M8')),
credits Number(2) CONSTRAINT ck_credits CHECK(credits in (10, 20, 40)),
constraint pk_mv primary key(moduleId)
create table sa (
stuId Char(2) CONSTRAINT ck_stuId CHECK(stuId in ('S1', 'S2', 'S3', 'S4', 'S5')),
moduleId Char(2),
constraint pk_sa primary key(stuId, moduleId),
constraint fk_moduleid foreign key(moduleId) references mv(moduleId)
And the scripts below is to insert data into both:
insert into mv VALUES('M1', 20)
insert into mv VALUES('M2', 20)
insert into mv VALUES('M3', 20)
insert into mv VALUES('M4', 20)
insert into mv VALUES('M5', 40)
insert into mv VALUES('M6', 10)
insert into mv VALUES('M7', 10)
insert into mv VALUES('M8', 20)
insert into sa VALUES('S1', 'M1')
insert into sa VALUES('S1', 'M2')
insert into sa VALUES('S1', 'M3')
insert into sa VALUES('S2', 'M2')
insert into sa VALUES('S2', 'M4')
insert into sa VALUES('S2', 'M5')
insert into sa VALUES('S3', 'M1')
insert into sa VALUES('S3', 'M6')
Now for the actual problems.
Firstly I need to try and overcome the mutating table problem by ensure that stuid = S1 in table sa can not take both moduleId M5 and M6.
Just one or the other. I have created a single trigger, but if fails because of the mutating table problem.
The second problem I need to overcome is that none of the stuids can have moduleIds where total credit value of more than 120 credits. Credit value is stored in the mv table.
Many thanks in advance for any assistance.Use a statement level trigger:
Firstly I need to try and overcome the mutating table problem by ensure that stuid = S1 in table sa can not take both moduleId M5 and M6.
SQL> create or replace trigger sa_trg
2 after insert or update on sa
3 declare
4 c number;
5 begin
6 select count(distinct moduleId) into c
7 from sa
8 where stuid = 'S1'
9 and moduleId in ('M5','M6');
10 if c > 1 then
11 raise_application_error(-20001,'S1 on both M5 and M6!!');
12 end if;
13 end;
14 /
Trigger created.
SQL> select * from sa;
ST MO
S1 M1
S1 M2
S1 M3
S2 M2
S2 M4
S2 M5
S3 M1
S3 M6
8 rows selected.
SQL> insert into sa values ('S1','M5');
1 row created.
SQL> insert into sa values ('S1','M6');
insert into sa values ('S1','M6')
ERROR at line 1:
ORA-20001: S1 on both M5 and M6!!
ORA-06512: at "SCOTT.SA_TRG", line 9
ORA-04088: error during execution of trigger 'SCOTT.SA_TRG'
The second problem I need to overcome is that none of the stuids can have moduleIds where total credit value of more than 120 credits. Credit value is stored in the mv table
SQL> create or replace trigger sa_trg
2 after insert or update on sa
3 declare
4 c number;
5 begin
6 select count(distinct moduleId) into c
7 from sa
8 where stuid = 'S1'
9 and moduleId in ('M5','M6');
10 if c > 1 then
11 raise_application_error(-20001,'S1 on both M5 and M6!!');
12 end if;
13
14 select count(*) into c from (
15 select stuid
16 from mv, sa
17 where sa.moduleid=mv.moduleid
18 group by stuid
19 having sum(credits)>120);
20
21 if c > 0 then
22 raise_application_error(-20002,'A student cannot have more than 120 credits!!');
23 end if;
24
25 end;
26 /
Trigger created.
SQL> select stuid, sum(credits)
2 from mv, sa
3 where sa.moduleid=mv.moduleid
4 group by stuid;
ST SUM(CREDITS)
S3 30
S2 80
S1 100
SQL> insert into sa
2 values ('S1','M4');
1 row created.
SQL> select stuid, sum(credits)
2 from mv, sa
3 where sa.moduleid=mv.moduleid
4 group by stuid;
ST SUM(CREDITS)
S3 30
S2 80
S1 120
SQL> insert into sa
2 values ('S1','M7');
insert into sa
ERROR at line 1:
ORA-20002: A student cannot have more than 120 credits!!
ORA-06512: at "SCOTT.SA_TRG", line 20
ORA-04088: error during execution of trigger 'SCOTT.SA_TRG'Max
http://oracleitalia.wordpress.com -
hello gurus,
I want to check whether a perticular file present on the application server or not
if yes
I want to delete it.
if no
i want to create the file in append mode.
I know its a simple issue but still i havnt done file IO in sap yet so please help me in this issue.
Thanks in advence!!!Hi Nikhil,
It is very simple.
1. open dataset <dset> for input.
If the file is existing, you will get sy-subrc = 0, else sy-subrc = 8.
2. if sy-subrc = 0 DELETE DATASET <dset>
3. else.
OPEN DATASET <dset> for APPENDING.
Ravi -
Table Maintanance Help Required
Hi All,
I am using two screens in my table maintanace. I am doing all my validations in screen2.After entering the data when i click on save button Ztable will update. this is working fine for single entry. When i am entering multiple entries for example both entries are duplicate then it is giving error message like duplicate entry after this displaying this message when i click on EXIT button unique record is showing in screen 1.
my two entries are
1. runrate maheed a01
2. runrate maheed a01
uniure record means single record i.e. runrate maheed a01 is showing on first screen. actually i dont want to display this entry in screen 1. is this possible if not please tell me any other alternate is exist.
Thanks,
Maheedahr.THi ,
Please check the primary key combination of the z table. it do not allow you to insert 2 records with same primary key fields value.
regards,
Tanmay -
Calcullating no. of records in an internal table based on condition
Hi,
i have several records in an internal table. i need to calculate the number of records which meets a condition. is there any simple logic to find the records which meet the required criteria apart from looping into the internal table.
your help would be appreciated.
Thanks,
kranthi.Hi,
U can use sy-dbcnt after the select querry.
DBCNT Number of elements in edited dataset with DB operations
WRITE: /12 'Number of selected records:', SY-DBCNT CENTERED.
REPORT ZZZ_TEST1 .
Tables: mara.
Types: begin of ty_mara,
matnr like mara-matnr,
end of ty_mara.
DATA: i_mara TYPE STANDARD TABLE OF ty_mara.
DATA: v_cnt like sy-dbcnt.
SELECT-OPTIONS: s_matnr FOR MARA-matnr.
SELECT matnr from mara into table i_mara.
if sy-subrc = 0.
v_cnt = sy-dbcnt.
WRITE: /12 'Number of selected records:', v_cnt CENTERED.
endif.
Hope this helps u.
Thanks & Regards,
Judith.
Maybe you are looking for
-
Does iDVD actually convert NTSC/PAL?
I was just dozing on the bed and had a moment of clarity... Well, I've recently got a new iMac and got into this DVD thing I shoot movies of my family and send them back home on DVD. I'm in Japan (NTSC) and the family's back in England (PAL). My came
-
Facetime camera settings on Macbook Pro Retina
Just purchased a new Macbook Pro Retina 13". FaceTime camera settings do not permit adjusting picture. The image is terrible. How can I correct this, or is reliable third party software available for this purpose?
-
Applying a stroke color to a rectangle
Hi All, I want to apply "Red", "Yellow", "Green" one at a time as a stroke color to the rectangle On looking into the pageitem property I have found that I can do the above thing as follows selectedPageItem.strokeColor = MyColor But the above proprty
-
Printing to Acrobat 5.0 from Indesign CS3
Hi I dont get it!! Do i need to install the entire Adobe Acrobat 5.0 (1.4) when wanting to print to Acrobat 5.0 from Indesign when choosing .ppd? thanks!
-
Trying to, one, navigate this process, and, two, not have my calendar post everything twice, then delete both entries when I try to clean it all up. Trying to navigate between iphone, imac and ipad, and would like to set up calendar accts for one mo