Problem in Internal table Record Splitting
Hi All,
Plz look into my below requirement and me know your Suggestions.
My Internal tables :
1.*Internal table for Infotype 2002 (Attendances)
DATA : BEGIN OF T_PA2002 OCCURS 0,
PERNR LIKE PA2002-PERNR,
BEGDA LIKE PA2002-BEGDA,
ENDDA LIKE PA2002-ENDDA,
BEGUZ LIKE PA2002-BEGUZ,
ENDUZ LIKE PA2002-ENDUZ,
SUBTY LIKE PA2002-SUBTY,
END OF T_PA2002.
1.*Internal table for Infotype 9003 (Custom Attendances)
DATA : BEGIN OF T_PA9003HRABS OCCURS 0,
PERNR LIKE PA9003-PERNR,
BEGDA LIKE PA9003-BEGDA,
ENDDA LIKE PA9003-ENDDA,
SHIFT LIKE PA9003-SHIFT,
OTHOURS LIKE PA9003-OTHOURS,
BEGUZ LIKE PA2002-BEGUZ,
ENDUZ LIKE PA2002-ENDUZ,
NSA LIKE PA9003-NSA,
MA LIKE PA9003-MA,
CA LIKE PA9003-CA,
END OF T_PA9003HRABS.
Requirement :
1. Internal table T_PA2002
PERNR BEGDA ENDDA BEGUZ ENDUZ
5 27.12.2006 27.12.2006 10:00:00 14:30:00
2. Internal table T_PA9003HRABS
PERNR BEGDA ENDDA BEGUZ ENDUZ HRABS OTHOURS MA CA WA
5 27.12.2006 27.12.2006 08:00:00 14:30:00 2 2
Iam doing comparision between T_PA2002 and T_PA9003HRABS.
Iam doing some caluculation to get Hourly absence,OT Hours and else ( Fields)
So my Hourly absence on 27.12.2006 was 2Hours.
So i need to split my Final table as below how to do that....( It is like In infotypes COPY option i.e 1 record to 3 Record )
I need the Output like this...
3. Final Internal table T_PA9003HRABS
PERNR BEGDA ENDDA BEGUZ ENDUZ HRABS OTHOURS MA CA WA
5 25.12.2006 26.12.2006 08:00:00 14:30:00 0 0
5 27.12.2006 27.12.2006 08:00:00 14:30:00 2 2
5 25.12.2006 26.12.2006 08:00:00 14:30:00 0 0
Points will be rewarded.
Thanks,
Suresh.U
you could:
sort T_PA2002 by pernr.
sort T_PA9003HRABS by pernr.
loop at T_PA2002
read table T_PA9003HRABS with key
pernr = T_PA2002-pernr
begda = T_PA2002-begda
binary search.
***here you can specify how you calculate
***your absences and apply them to your
***final internal table.
endloop.
hope this helps.
Warren
Similar Messages
-
Refresh internal table records in web dynpro
Hi Guru's
I am facing an issue in web dynpro abap.
in my application there is a button called OPEN.
when i click on open button internal table records should be refreshed.
so i have written code like this
DATA lo_COMPONENTCONTROLLER TYPE REF TO IG_COMPONENTCONTROLLER .
lo_COMPONENTCONTROLLER = wd_this->get_componentcontroller_ctr( ).
lo_componentcontroller->clear_info_refresh_visible( ).
but iam getting an error message Method "CLEAR_INFO_REFRESH_VISIBLE" is unknown or PROTECTED or PRIVATE
Could you please help me to how do i activate and refresh the things.
Thanks
Rajuewd.rajue wrote:
Hi Guru's
>
> I am facing an issue in web dynpro abap.
> in my application there is a button called OPEN.
> when i click on open button internal table records should be refreshed.
> so i have written code like this
>
> DATA lo_COMPONENTCONTROLLER TYPE REF TO IG_COMPONENTCONTROLLER .
>
> lo_COMPONENTCONTROLLER = wd_this->get_componentcontroller_ctr( ).
>
> lo_componentcontroller->clear_info_refresh_visible( ).
>
>
>
> but iam getting an error message Method "CLEAR_INFO_REFRESH_VISIBLE" is unknown or PROTECTED or PRIVATE
>
>
> Could you please help me to how do i activate and refresh the things.
>
> Thanks
> Rajue
Raju,
Please clarify this.
Do you have a method clear_info_refresh_visible in your component controller. I think not.
I am not able to relate your request and coding.
You can simply clear the internal table like this
clear lt_intern_tab[].
If it is a context node then you can bind a empty table to the node to make it empty.
lo_nd_data->bind_table(
new_items = lt_intern_tab
set_initial_elements = abap_true ). -
I am getting problem with internal table & work area declaration.
I am working with 'makt' table ..with the table makt i need to work with styles attributes ..so i declared like this
TYPES : BEGIN OF ty_makt,
matnr TYPE makt-matnr,
spras TYPE makt-spras,
maktx TYPE makt-maktx,
maktg TYPE makt-maktg,
celltab TYPE lvc_t_styl,
END OF ty_makt.
DATA : i_makt TYPE TABLE OF ty_makt.
DATA : wa_makt TYPE ty_makt .
But end of program i need to update dbtable "makt"...i am getting problem with internal table & work area declaration.
i think makt table fields mapping and internal table/work area mapping is not correct. so please help me to get out from this.Hi Nagasankar,
TYPES : BEGIN OF TY_MATNR,
MATNR TYPE MAKT-MATNR,
SPRAS TYPE MAKT-SPRAS,
MAKTX TYPE MAKT-MAKTX,
MAKTX TYPE MAKT-MAKTG,
CELLTAB TYPE LVC_T_STYL, " Its Working perfectly fine..
END OF TY_MAKT.
DATA: IT_MAKT TYPE STANDARD TABLE OF TY_MAKT,
WA_MAKT TYPE TY_MAKT.
Its working perfectly fine. if still you are facing any issue post your complete code.
Thanks,
Sandeep -
How to display the Internal table records in table format?
Hi Gurus,
I want to display my print prg internal table records in d appropriate form in a table format, give some solution
with regards
ThambeThere are lot many options to do that
one way is create template in the maikn window and define the line types according to your data cretae text and put your data in the text and go to output options and give the line type to be used . You can also select details option to have lines in your output.
similarly YOU CAN CREATE TABLE IN THE MAIN WINDOW FOR THIS YOU DONT NEED TO DEFINE THE LINE TYPES .
WHEN YOU ARE IN MAIN WINDOW RIGHT CLICK ON TABLE AND GO TO PATH
CREATE -> TABLE
-> TEMPLATE
REWARD IF USEFUL
Regards,
Nageswar -
Function module for move internal table records into MSexcel file
Hi all,
Tell me the function module which is used to
move internal table records in to MSexcel file.
Give the sample program...Please search the forum for FM "GUI_DOWNLOAD" You will get tons of threads with sample code.
Also take a look into SAP_CONVERT_TO_XLS_FORMAT
Thanks -
Help on Delete Internal table records
Hi,
I have a internal table with some records in it.
I need to delete the contents of this based on the condition as below.
if product_search-Resp_product_company is not initial.
SORT i_equi BY zzrefeng.
DELETE i_equi WHERE zzrefeng <> product_search-Resp_product_company.
endif.
when i execute this all the records are getting deleted irrespective of the condition mentioned.
Can anyone help me on this.
Regards,
RamHi,
Need to delete the records if <b>ZZREFENG</b> does not have the value of <b>product_search-Resp_product_company</b> .
Here I have product_search-Resp_product_company value as FI14. And also the internal table contains some records with ZZREFENG = FI14.
I need to delete the internal table records if ZZREFENG <> FI14. But when i execute the statement it is deletng all the records even ZZREFENG = FI14 records also.
Regards,
Ram -
Problem to upload the data into internal table record length more than 6000
Hi all
I stuck with this problem from past 3 days. I have to upload the data from excel sheet. iam making it tab delimited and trying to upload from gui_upload. but in the structure of file, we have, one field of 4000 characters, and other fields of 255 characters.
how can i upload this into internal table . From excel sheet or from tab delimeted or any other format? or any special function module is there? while iam doing this its truncating the datat 255 characters and not uploading the other fields also...
can any one of you help me out. ASAP
thnks in advancefrom one of the forum iam just pasting code which it is used in lsmw, try the same logic in ur code hope it can work.
you have to create multiple lines with do...enddo loop., like this:
(assuming excel_long_text-text is 924 characters long, 7 lines X 132 char)
__GLOBAL_DATA__
data: offset type i,
text_132(132) type c.
__BEGIN_OF_RECORD__ Before Using Conversion Rules
Rule : Default Settings Modified
Code: /sapdmc/ltxtl = init_/sapdmc/ltxtl.
CLEAR offset.
DO 7 TIMES.
text_132 = excel_long_text-text+offset(132).
offset = offset + 132.
__END_OF_RECORD__ After Using Conversion Rules
Rule : Default Settings Modified
Code: transfer_record.
ENDDO.
also check this
COMMIT_TEXT
To load long text into SAP
READ_TEXT
To load long text into SAP -
How to send Internal table records to Idoc Inbound posting FM to create Ido
Hello Experts,
I have all the data necessary to create shipments in one internal table inside my ABAP program.
I can use BAPI_SHIPMENT_CREATE to create shipments. But associated with this BAPi there is one ALE message type SHIPMENT_CREATEFROMDATA. Now my requirement is to use this message type to cretae my shipments via idocs for one scenario for some of the records in the internal table.
For this message type, I got the inbound function module IDOC_INPUT_SHIPMENT_CREATEFROM from TBDBE table.
Can anybody please let me know how to send the data from the internal table to this inbound function module?
Becasue it has mandatory parameters INPUT_METHOD, MASS_PROCESSING. What values should be passed to these parameters if the data has to be sent to this function module?
Regards.Hi Ravikanth,
Thankyou very much for your quick reply.
So If I split my internal table data and populate IDOC_DATA and IDOC_CONTROL and pass to the inbound function module directly in my ABAP program, will that be going to create idocs and post shipments?
I mean is it enough to call the Inbound posting function module directly in my ABAP program or any other FMs to be called to take care of ALE settings and shipment creation?
Please confirm.
REgards. -
Doubt in internal table records
Hi all,
I have a one problem, in my internal table have 5 records. i did some correction in my progm after i execute the loop i need the correction in the records. In debug mode it showing in the header level. but it not changing the body records. give some soln.
Thanks,
gowrihi,
chk the code below:
loop at itab.
modify itab index sy-tabix.
endloop.
regards,
Navneeth K. -
Internal table record checking (Urgent)
Hi Experts,
I have an internal table having records. I want to check each record of the table with every other record to find out if there exist same record for more then one key field.
Can anybody help me to place the logic for how i can check the records with each record? Like
lifnr banks
1 12
2 34
3 12
4 12
5 76
I want to find out 1,3 and 4.
Thanks a ton in advanceHi Moni,
IF in my First Reply the Second technique was working then this should solve your Problem:
DATA:
w_index TYPE i,
w_lines TYPE i,
w_duplicate(10) TYPE c.
DESCRIBE itab LINES w_lines.
LOOP AT itab INTO wa.
w_index = sy-tabix + 1.
DO.
READ TABLE itab INTO wa1 INDEX w_index.
IF w_index <= w_lines.
IF wa-banks EQ wa1-banks.
CONCATENATE w_duplicate wa1-lifnr INTO w_duplicate SEPARATED BY SPACE.
wa-duplicate = w_duplicate.
MODIFY itab FROM wa.
ENDIF.
ELSE.
EXIT.
ENDIF.
ADD 1 TO w_index.
ENDDO.
ENDLOOP.
LOOP AT itab INTO wa.
write:
/ wa-lifnr,
wa-banks,
wa-duplicates.
ENDLOOP.
ELSE try the below code it is same as above except one more Internal Table is used:
DATA:
w_index TYPE i,
w_lines TYPE i,
jtab LIKE itab,
w_duplicate(10) TYPE c.
DESCRIBE itab LINES w_lines.
LOOP AT itab INTO wa.
w_index = sy-tabix + 1.
DO.
READ TABLE jtab INTO wa1 INDEX w_index.
IF w_index <= w_lines.
IF wa-banks EQ wa1-banks.
CONCATENATE w_duplicate wa1-lifnr INTO w_duplicate SEPARATED BY SPACE.
wa-duplicate = w_duplicate.
MODIFY itab FROM wa.
ENDIF.
ELSE.
EXIT.
ENDIF.
ADD 1 TO w_index.
ENDDO.
ENDLOOP.
LOOP AT itab INTO wa.
write:
/ wa-lifnr,
wa-banks,
wa-duplicates.
ENDLOOP.
Regards,
Sunil. -
Reg : Joining the all internal table records into a single internal table
Hi all
I am having 5 internal tables and i want to put all these entries in a single intrnal table and my requirement is for each and every record it has to go through all the internal tables and if an entry is missing meand.it has to go through the other internal tables and for missing entries i should leave it as blank and rest of the contents i have to display can any please gimme some logic how to do this??
Thanks in advanceDon't have time or will to deliver turnkey solutions, but here is a frame:
LOOP AT itab1...
READ TABLE itab2 WITH TABLE KEY... (fields linking itab1 and itab2)
READ TABLE itab3 WITH TABLE KEY... (fields linking itab1 and itab3)
LOOP AT itab4 WHERE... (fields linking itab1 and itab4)
READ TABLE itab5 WITH TABLE KEY... (fields linking itab4 and itab5)
MOVE-CORRESPONDING... (all five work areas to target work area)
APPEND itabtarget...
ENDLOOP.
ENDLOOP.
so use READ when there is a 1:1 relationship (e.g. check table entry), and LOOP when there is a 1:N relationship (e.g. items for a header)
Thomas -
HI,
I need to DMBE2 value as with respective of Month, Year and Inception date.
I need the output to be like
HKONT BLART PRCTR DMBE2(Month) DMBE2 (Year) DMBE3 (Year)
Below is my code
DATA : BEGIN OF gt_lkorr OCCURS 0,
hkont LIKE bsis-hkont,
prctr LIKE bsis-prctr,
bewar LIKE bsis-bewar,
dmbe2 LIKE bsis-dmbe2,
belnr LIKE bsis-belnr,
budat LIKE bsis-budat,
monat LIKE bsis-monat,
gjahr LIKE bsis-gjahr,
blart LIKE bsis-blart,
shkzg like bsis-shkzg,
END OF gt_lkorr.
*DATA : wa_lkorr LIKE gt_lkorr OCCURS 0 WITH HEADER LINE.
DATA : BEGIN OF wa_lkorr OCCURS 0,
hkont LIKE bsis-hkont,
prctr LIKE bsis-prctr,
bewar LIKE bsis-bewar,
dmbe2 LIKE bsis-dmbe2,
belnr LIKE bsis-belnr,
budat LIKE bsis-budat,
monat LIKE bsis-monat,
gjahr LIKE bsis-gjahr,
blart LIKE bsis-blart,
dmbe2_2 LIKE bsis-dmbe2,
dmbe2_3 LIKE bsis-dmbe2,
END OF wa_lkorr.
DATA : gt_final_lkorr LIKE wa_lkorr OCCURS 0 WITH HEADER LINE.
FORM f_get_t030hb_tr.
SELECT hkont lkorr FROM t030hb INTO CORRESPONDING FIELDS OF
TABLE gt_tr_t030hb
WHERE ktopl = 'KCOA'
AND bwber = 'TR'
AND hkont IN so_hkont.
IF gp_pprct IS INITIAL.
SELECT hkont prctr bewar dmbe2 belnr budat monat gjahr blart
FROM bsis INTO CORRESPONDING
FIELDS OF TABLE gt_lkorr FOR ALL ENTRIES
IN gt_tr_t030hb
WHERE bukrs IN so_bukrs
AND gjahr IN so_gjahr
AND prctr IN so_prctr
AND hkont = gt_tr_t030hb-lkorr
AND vbund IN so_vbund.
ELSE.
LOOP AT gt_prctr.
SELECT hkont prctr bewar dmbe2 belnr budat monat gjahr blart
FROM bsis INTO CORRESPONDING
FIELDS OF TABLE gt_lkorr FOR ALL ENTRIES
IN gt_tr_t030hb
WHERE bukrs IN so_bukrs
AND gjahr IN so_gjahr
AND prctr = gt_prctr-prctr
AND hkont = gt_tr_t030hb-lkorr
AND vbund IN so_vbund.
ENDLOOP.
ENDIF.
DELETE ADJACENT DUPLICATES FROM gt_lkorr COMPARING ALL FIELDS.
ENDFORM. "f_get_t030hb_tr
*& Form f_get_yearwise_data
text
FORM f_get_yearwise_data.
DATA : lv_period LIKE t009b-poper.
DATA : lv_year LIKE bsis-gjahr,
lv_dmbe2 LIKE bsis-dmbe2.
LOOP AT gt_lkorr.
CALL FUNCTION 'DATE_TO_PERIOD_CONVERT'
EXPORTING
i_date = sy-datum
I_MONMIT = 00
i_periv = 'K4'
IMPORTING
e_buper = lv_period
E_GJAHR =
EXCEPTIONS
input_false = 1
t009_notfound = 2
t009b_notfound = 3
OTHERS = 4
IF gt_lkorr-monat EQ lv_period.
wa_lkorr-hkont = gt_lkorr-hkont.
wa_lkorr-prctr = gt_lkorr-prctr.
wa_lkorr-bewar = gt_lkorr-bewar.
wa_lkorr-dmbe2 = gt_lkorr-dmbe2.
wa_lkorr-blart = gt_lkorr-blart.
if gt_lkorr-shkzg = 'H'.
wa_lkorr-dmbe2 = - wa_lkorr-dmbe2.
endif.
COLLECT wa_lkorr.
endif.
ENDLOOP.
LOOP AT wa_lkorr INTO gt_final_lkorr.
write : / gt_final_lkorr-hkont,
gt_final_lkorr-prctr,
gt_final_lkorr-bewar,
gt_final_lkorr-dmbe2,
gt_final_lkorr-blart.
ENDLOOP.
write : ' Inception to date'.
LOOP AT gt_lkorr.
CALL FUNCTION 'DATE_TO_PERIOD_CONVERT'
EXPORTING
i_date = sy-datum
I_MONMIT = 00
i_periv = 'K4'
IMPORTING
e_buper = lv_period
e_gjahr = lv_year
EXCEPTIONS
input_false = 1
t009_notfound = 2
t009b_notfound = 3
OTHERS = 4
IF gt_lkorr-gjahr EQ lv_year.
wa_lkorr-hkont = gt_lkorr-hkont.
wa_lkorr-prctr = gt_lkorr-prctr.
wa_lkorr-bewar = gt_lkorr-bewar.
wa_lkorr-dmbe2 = gt_lkorr-dmbe2.
wa_lkorr-blart = gt_lkorr-blart.
if gt_lkorr-shkzg = 'H'.
wa_lkorr-dmbe2 = - wa_lkorr-dmbe2.
endif.
COLLECT wa_lkorr.
endif.
ENDLOOP.
LOOP AT wa_lkorr into gt_final_lkorr.
WRITE : / gt_final_lkorr-hkont,
gt_final_lkorr-prctr,
gt_final_lkorr-bewar,
gt_final_lkorr-dmbe2,
gt_final_lkorr-blart.
move : wa_lkorr-dmbe2_2 to gt_final_lkorr-dmbe2_2.
modify gt_final_lkorr.
clear gt_final_lkorr.
ENDLOOP.
loop at gt_lkorr.
wa_lkorr-hkont = gt_lkorr-hkont.
wa_lkorr-prctr = gt_lkorr-prctr.
wa_lkorr-bewar = gt_lkorr-bewar.
wa_lkorr-dmbe2 = gt_lkorr-dmbe2.
wa_lkorr-blart = gt_lkorr-blart.
if gt_lkorr-shkzg = 'H'.
wa_lkorr-dmbe2 = - wa_lkorr-dmbe2.
endif.
COLLECT wa_lkorr.
ENDLOOP.
LOOP AT wa_lkorr into gt_final_lkorr.
WRITE : / gt_final_lkorr-hkont,
gt_final_lkorr-prctr,
gt_final_lkorr-bewar,
gt_final_lkorr-dmbe2,
gt_final_lkorr-blart.
ENDLOOP.
Please let me know how to do it?
Thanks,
Pavan.I think you need to insert a field in your wa_lkorr internal table for key which you should populate as M for month data, Y2 for Year data and Y3 for dmbe3 data.
So when you want to display they are three different records. -
Data fetching problem in internal table
Hi All,
I have two internal table which are of type as shown below.
itab1 is of following type:
regno(255) type c,
uid type c
itab2 is of following type
regno type regno,
uid type userid,
address type add,
phno type phn.
Datas in itab2 are as follows:
100 01 india 3454534
200 01 china 34553543
300 02 us 6464654
400 02 uk 45654
Itab1 is populated using the uid field as key as shown below.
regno uid
100 200 01
300 400 02
100 200 are values in field regno
01 is uid.
What we have done is collected all the regno which belong to the same uid for sending a single mail to the uid person with both the regno. We are able to achieve this. For this finally we loop into itab1 and fetch the uid and send mail to him.
Now an extra requirement is to send the details of a regno (address and phno) along with the mail. The prob is in our final internal table we have a character field which will have all the regno for a uid (may be upto 20). Each regno will be of length 3.
I have to loop into tab1 and read tab2 to achieve this using uid as key. But regno will for a uid will be combined. I have fetch each regno say 100 first and get the details and then 200 and then get the details and send a mail to uid 01. Then 300 and 400 details and then a mail to uid 02.
Please explain how to get individual regno when i loop into tab1 and read tab2 so that i can fetch the details.
Any suggestion will be very helpfulHi Aslam,
As per my understanding...
In itab1, instead of maintaining all the reg no in the same field(like 100 200 300 ....) againist uid 01
maintain multiple records like
regno udi
100 01
200 01
300 01 etc
(in this case the combination of regno & uid becomes the key.)
now while ur sending mail to the people, just loop the recors of itab1
in the same loop u can just write a read statement to get the remainig details(address, phone no etc..) of that regno from itab2.
Hope this helps you, revert back if still u hav any problm. -
Doubt in internal table record count
Hi,
i have an internal table with 5 fields. Last field is flag. In my internal table lot many records are there. i want to count only the records with flag 'E'. How to count the total records with 'E'.
MohanaTry like this,
Data: c type i.
Loop at itab into wa.
if wa-flag = 'E'.
c = c + 1.
endif.
Endloop.
Write:/ 'Total records', c.
OR
LOOP AT itab WHERE flag = 'E'.
c = c + 1.
ENDLOOP.
Edited by: Sap Fan on Apr 3, 2009 5:21 PM -
Memory problems in internal table
Hi,
I am facing an issue with the internal table memory.
I am selecting something from the database and putting it in internal table but the load is so much that it is giving me memory errors as the data may go into millions.
So what we have decided is to cut down the data in the internal table. we have defined a variable which will contain suppose 30000 data.
so what i mean to do is to take the records from the databas based on the value in the variable. By that way i will be taking only 30000 data each time.
But the issue is that first time it will take 1 to 30000 records if i give upto 30000 rows in the select query.. but then how will i take 30001 to 60000 the next time.. by that i mean how will i keep incrementing in the select query.
Thanks in advance.
Amit KurupHi
I've never used these stataments but perhaps they are usefull for you:
See the help for OPEN/CLOSE/FETCH CURSOR
DATA: C TYPE CURSOR,
WA TYPE <TABLE>.
DATA: ITAB LIKE STANDARD TABLE OF <TABLE>.
OPEN CURSOR C FOR
SELECT * FROM <TABLE> WHERE .......
DO.
FETCH NEXT CURSOR C TO WA.
IF SY-SUBRC <> 0.
CLOSE CURSOR C.
EXIT.
ENDIF.
APPEND WA TO ITAB.
IF COUNT = 30000.
DO SOMETHING
COUNT = 0.
REFRESH ITAB.
ENDIF.
COUNT = COUNT + 1.
ENDDO.
Max
Maybe you are looking for
-
Multiple attachment download in mail
Have an email with 18 attachments (word and excel stuff) is my only option to click (or right-click) each one to download them?? or is there a quicker (read simpler) way. This is via web browser iCloud, as I'm running an older macbook Pro.....
-
iPopd touch 4th generation sleep/power button not working. Any ideas? how long is warranty?
-
I share a song to itunes that I made in garageband.
I can then use an equalizer and tweek the song and make that equalizer a preset for that song. Will that preset still be inefect when i use that song in imovie11?
-
How to Export only some tables with procedures and packages
Hi... I want to export only some tables and packages and procedures. Can anybody please guide me how to do this. Thanks in advance....... pal
-
30GB 5G only recognised in Device Manager
Hi, wondered if someone could help. Although new to the forum i have extensively read many of the other posts along with apple support and realise there is a problem with the 5G ipods and windows XP; however, no suggested solutions (even from apple,