Internal table fields
Hi,
I have two internal tables.itab1 and itab2.
The sturcture of both the tables are as:
begin of itab1
kunnr
name1
end of itab1.
begin of itab2
ort01
name1
land1
end of itab2.
now, i have data in both the tables using select statement.
Requiement is like this :
i want to check if value of field name1 is availabe in itab1. if itab1-name1 is not having any values then i want to update this field of itab1 with name1 of tale itab2.
i.e. in place of blank values of field itab1-name1 , i want to replcae this null value with values from itab2-name1.
Any help will be appricitated.
Thanks
Hi,
U can try the following code.
loop at itab1 into wa1.
if wa1-name1 eq space.
read table itab2 into wa2 with key ort01 = kunnr.
wa1-name1 = wa2-name1.
modify table itab1 from wa1 transporting name1.
endif.
clear: wa1,wa2.
endloop.
reward points if helpful.
regards,
Ravi G
Similar Messages
-
Regarding Internal Table Field Validation [Modification]
Hi All,
I have a small issue with formatting of a field.
The Field is POTX1 - it would get the value as 'New MT-EPPE0097-COMP02',
Means i have one internal table field as i_error-POTX1 in that some times we get value as 'New MT-EPPE0097-COMP02'.
Whenever i get 'New' literal in that internal table field i have to remove that literal from that internal table field. And Left Justify the remaining part of the field.
Ex: 'New MT-EPPE0097-COMP02'
should become 'MT-EPPE0097-COMP02'.
For this first i have to find wether 'New' Literal exists in the Internal table field or not then i have to remove it.
Can anybody tell me how can i solve this issue.
Thanks in advance.
Thanks & Regards,
Rayeezuddin.Hi,
Take a look :
loop at i_error.
if i_error-potx1(3) = 'New'
w_potx1 = i_error-potx1.
i_error-potx1 = w_potx1+3(37).
MODIFY i_error.
endif.
ENDLOOP.
Regards,
Erwan.
Message was edited by: Erwan LE BRUN -
Assigning value to Field - Symbol ( which is type of internal table field )
Hi All,
I am facing problem to assign the value to a field symbol. My requirement is creating a dynamic internal table and populate values into that internal table, so that i can display the values .
I am having a structure with fields like status , Plant1 name , Plant2 name.....Plant n .
So i declared an internal table it_tab with this structure.
I am having one more table which having number of records for Plant1 ,Plant 2 ,....Plant n based on some condition.
I need to count the number of records for Plant1 and i need to put in the internal table it_tab.
For this i created field-symbol .
Here, t_deployment table will have the plants 1,2,3...and
t_devobject will have some records for these plants.
LOOP AT T_DEPLOYMENT.
clear w_count.
LOOP AT T_DEVOBJECT WHERE ZDEPLOYMENT = T_DEPLOYMENT-DOMVALUE_L AND
ZADSTATUS = '10'.
w_count = w_count + 1.
ENDLOOP.
concatenate 'it_tab-' t_deployment-domvalue_l into var_bet_name.
assign var_bet_name to <bet_var_name>.
now my internal table field i.e. it_tab-plant1 came into <bet_var_name> . But i want to assign a value for it.
at last what i need is it_tab-plant1 = w_count.
whaterver the w_count has value that needs to assign to it_tab-plant1. But i don't want to assign directly it it_tab-plant1. I want to assign dynamically. Because tommorrow some more plants added to t_deployments , i don't want to make changes to my program. It should take care....w/o changing the program.
I tried the following statement.
(<bet_var_name>) = w_count. But its not working.
Please let me know how i can get this.
Thanks in Advance.
Pavan.Hi pavan,
As ur requirement is creating a dynamic internal table,
try the following way,
remember the fieldcat should be of type LVC not SLIS.
BUILD LT_LVCFIELDCAT in a way that, the value from the internal table becomes the fieldname
ex:-
loop at it_models INTO WA_MODELS.
LS_LVCFIELDCAT-FIELDNAME = WA_models-MODEL.
LS_LVCFIELDCAT-SELTEXT = WA_models-MODEL.
append ls_lvcfieldcat to lt_lvcfieldcat.
endloop.
DATA: DREF TYPE REF TO DATA,WA_REF TYPE REF TO DATA.
FIELD-SYMBOLS: <TEMP_TAB> TYPE TABLE, <TEMP_WA> TYPE ANY.
CALL METHOD CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE
EXPORTING
IT_FIELDCATALOG = LT_LVCFIELDCAT
IMPORTING
EP_TABLE = DREF.
ASSIGN dref->* TO <TEMP_TAB>.
now basing on the fieldcatalog <temp_tab> is build.
NOW FILL <TEMP_TAB>.
WHILE FILLING, ASSIGN COMPONENT IDX/NAME.....
this statement will be very usefull.
i hope this will be help full.
pls reward the points if it helps u.
regards
Hyma -
How to populate dynamic internal table fields with data??
Hi Folks,
How to assign a particular internal table field to a dynamically assigned internal table?
I have an excel sheet, and i upload the excel sheet data into an internal IT_EXLOAD table using FM ALSM_EXCEL_TO_INTERNAL_TABLE
Now i created a dynamic internal table which has the same column as in my DB table.
I have to fill the dynamically created Internal table with the IT_EXLOAD data dynamically.
Suppose in future if i add some field in DB table and for that field if i add some column in excel sheet there is no need to change in the program.
Looking for reply...
Best Regards,
Sayakhi,
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
filename = p_path
i_begin_col = '1'
i_begin_row = '2'
i_end_col = '2'
i_end_row = '1000'
TABLES
intern = intern
EXCEPTIONS
inconsistent_parameters = 1
upload_ole = 2
OTHERS = 3.
*declare intern_tmp as internal table tb_data in wich you want the data
*and declare a field symbol <fs_123>
LOOP AT intern.
ASSIGN COMPONENT intern-col OF STRUCTURE
intern_tmp TO <fs_123>.
IF NOT <fs_123> IS ASSIGNED.
CLEAR intern.
CLEAR intern_tmp.
CONTINUE.
ENDIF.
<fs_123> = intern-value.
AT END OF row.
CLEAR tb_data.
MOVE-CORRESPONDING: intern_tmp TO tb_data.
APPEND tb_data.
CLEAR intern_tmp.
ENDAT.
CLEAR intern.
ENDLOOP.
**paste this code and you can see the data in ur tables dynamically.
Thanks
Nitin Sachdeva -
An internal table field has been defined too small
Hi,
We are getting a dump when trying to get the Financial Statements.
The error in the dump is u201CAn internal table field has been defined too smallu201D.
The field with the problem is u201CYou should define the field "HSL03" larger in program "SAPLFAGL_GLT0".The maximum size allowed for fields of type P is 16 (31 digits).
Itu2019s caused by a list of documents where the exchange rate must to be u201D/699,94001u201D but it was entered without the forward slash and it caused very big numbers
The biggest number in one document is 99,401,074,527.31 USD
The sum of all them is 13,008,701,915,208.50
Any ideas to fix this?
Thanks in advance
Jorgehave you reversed those documents with fb08 and post it with the correct exchange rate???
have you searched in SMP for similar problems - I think you've to correct the DB-values- but only in agreement with your audit firm / revision
A.
Edited by: Andreas Mann on Apr 6, 2010 3:13 PM
Edited by: Andreas Mann on Apr 6, 2010 3:16 PM -
Accessing Dynamic Internal table fields
Hello All,
I have one internal table ep_tabx having 138 columns whose data is getting displayed
by using function module reuse_alv_grid_display.
Now my query is, i have created one custom button on the appl toolbar to download ep_tabx data.
IF the user changes the the layout of the output at runtime and then presses that custom button
then i have created one dynamic internal table using call method cl_alv_table_create=>create_dynamic_table suppose <dyn_table> whose struc will be that of
dynamic fieldcatalog returned by using FM REUSE_ALV_GRID_LAYOUT_INFO_GET.
And then I have put a loop on the int table ep_tabx and move corresponding to the int table
<dyn_table>. But when i download the <dyn_table> data through GUI_DOWNLOAD the
date fields data is not getting downloaded correctly. I have 4 date fields in my ep_tabx.
In the alv grid output the date is getting displayed like 08/30/2004(ie mon/date/yr) but in download
file it comes like 20040830(ie yr/mon/date and that too without /).How to access the dynamic
internal tables fields separately so asto convert them in the pgm before the download.
Kindly Help.
Thanks in advance.
MansiHi,
Search in SDN you would get loads of info on accessing dynamic itab's .
in order to convert your date format use WRITE stmt to convert the value in your itab before passing it to download FM.
Regards,
Raghavendra -
Coloring of Particular Cells in a dynamic internal table(field symbols)
Hi,
I have a requirement to introduce color into some particular cells in a dynamic internal table(Field symbol) based on some conditions.I know that color can be introduced at cell level in the case of static internal table.But, can anybody tell me whether it is possible to introduce color to particular cells in the dynamic internal table(Field Symbol) .Please suggest me on this issue.
Thanks in advance,
RajeshHi,
This is the sample coding for the colour cell report.
Kindly go through it. It will helps u.
REPORT YMS_COLOURTEST .
DATA: BEGIN OF TP OCCURS 10, ID, NR(8), TEXT(255), END OF TP.
DATA: LENGTH TYPE I VALUE 8, " Length of list
TESTSTRING(15) TYPE C VALUE '012345678901234',
WIDTH TYPE I. " Width of list
DATA: TXT_REPORT LIKE DOKHL-OBJECT.
START-OF-SELECTION.
PERFORM HEADING.
PERFORM OUTPUT_BODY.
FORM HEADING.
FORMAT INTENSIFIED OFF. " Remove any INTENSIFIED
ULINE AT (WIDTH). " Upper frame border
FORMAT COLOR COL_HEADING INTENSIFIED." Title color
WRITE: / SY-VLINE. " Left border
WRITE: 'No |Colour |intensified |intensified off|',
'inverse' NO-GAP.
WRITE: AT WIDTH SY-VLINE. " Right border
ULINE AT (WIDTH). " Line below titles
FORMAT COLOR OFF.
ENDFORM.
FORM OUTPUT_BODY.
DO LENGTH TIMES.
PERFORM WRITE_LINE USING SY-INDEX.
ENDDO.
ENDFORM.
FORM WRITE_LINE USING COUNT TYPE I.
DATA: HELP(14) TYPE C,
COUNT1 TYPE I.
COUNT1 = SY-INDEX - 1.
WRITE: / SY-VLINE NO-GAP.
WRITE: (4) COUNT1 COLOR COL_KEY INTENSIFIED NO-GAP.
WRITE: SY-VLINE NO-GAP.
CASE COUNT1.
WHEN '0'.
HELP = 'COL_BACKGROUND'.
WHEN '1'.
HELP = 'COL_HEADING'.
WHEN '2'.
HELP = 'COL_NORMAL'.
WHEN '3'.
HELP = 'COL_TOTAL'.
WHEN '4'.
HELP = 'COL_KEY'.
WHEN '5'.
HELP = 'COL_POSITIVE'.
WHEN '6'.
HELP = 'COL_NEGATIVE'.
WHEN '7'.
HELP = 'COL_GROUP'.
ENDCASE.
WRITE: HELP COLOR COL_KEY INTENSIFIED NO-GAP.
WRITE: SY-VLINE NO-GAP.
WRITE: TESTSTRING COLOR = COUNT1 INTENSIFIED NO-GAP.
WRITE: SY-VLINE NO-GAP.
WRITE: TESTSTRING COLOR = COUNT1 INTENSIFIED OFF NO-GAP.
WRITE: SY-VLINE NO-GAP.
WRITE: TESTSTRING COLOR = COUNT1 INVERSE NO-GAP.
WRITE AT WIDTH SY-VLINE NO-GAP.
ENDFORM.
Thanks,
Shankar -
How to check two internal table fields
Hi all,
I need to check two internal table fields are equal or not means which statement i can use.
Not internal table ,table contents i need to check i.e
it1-pernr = it2-pernr.
like this
if i put loop it'll check one table field for one loop.
if i put two loop means some fields reflecting 2 in it1 then it'll pring 4 times like that.i want to print whatever in internal table only .
pernr(0001) two times there in it1 means
it1-pernr = it2-pernr then
it's printing
0001
0001
0001
0001
like this but actually in it1 only two records.
Anybody know solution.tell me.
Thanks
Regards,
NandhaHi,
code for your view
data : begin of it1 occurs 0,
z_pernr like pa9012-pernr,
z_fac_c like pa9012-zz_fac_c,
end of it1.
data : it2 like Zsc1 occurs 0 with header line,
It1 data
pernr FAC C
0001 5555
0001 5555
0002 4444
0003 3333
0006 8888
It2 data
pernr FAC C
0001 5555
0001 5555
0005 6666
0003 3333
output(My code)
loop at it2 .
loop at it1 where pernr = it2-pernr.
write:/01 it1-1pernr,
10 it1-z_fac_c.
endloop.
endloop.
out put i need.
0001 5555
0001 5555
0002 4444
0003 3333
Thanks,
Nandha -
Regarding passing blank characters to internal table field
Hi All,
I have small issue.
Actual issue is
I am having one internal table field as <b>oper_table-arbid</b> in the program i will actually pass first 4 characters of that field into another internal table <b>i_download_operation-arbid.</b>
Then if <b>oper_table-arbid</b> is blank i need to pass
4 blank characters into <b>i_download_operation-arbid.</b>
Can anybody tell me how can i do it.
Code is like this
IF oper_table-arbid NE space.
MOVE oper_table-arbid+0(4) TO i_download_operation-arbid.
ELSE.
I need to pass 4 blank char's to i_download_operation-arbid
ENDIF.
oper_table-arbid is of 8 char length & i_download_operation-arbid is of 4 char length.
Can any body tell me what i need to do here.
Thanks in advance.
Thanks & Regards,
Rayeez.hi ,
shaik.
data: var(8) type c value 'abcdefgh'.
write var.
data: bar(8) type c value 'ijkl',
p1(8) .
move bar to p1.
write:/ p1 right-justified.
just execute the program and see the o/p.
if u r trying to pass character then default position is left-justfied .
so u need to explicitly say right-justified so it will take positions 5,6,7,8.
so here u need append blank spaces .
after seeing the o/p u will hav a clear picture .
vijay. -
Header to internal table fields
Hi All,
How can I add header description to the internal table fields and download this internal table to desktop as EXCEL form.
I want to show heading in the first line of the excel and then 2 - 3 blank lines and then next line should be populated with DATE and Exec. Time, then 2-3 blank lines , then the data with the header description to be displayed.
My sample internal table data is as below,
John M 12 2344
Thomas M 17 8960
Lin F 10 8467
Jan M 12 4323
I need to add, description as NAME above John, Thomas, Lin etc.
as GENDER above M,M,F etc.
as CODE above 12, 17,10 etc. and
as EXTENTION above 2344, 8960,8467 etc
final execl sheet should be as below,
COMPANY DATA
DATE 28 - 08 - 2009 TIME 12:32
NAME GENDER CODE EXTENTION
John M 12 2344
Thomas M 17 8960
Lin F 10 8467
Jan M 12 4323
Please let me know, how to do this.
Thanks in advance ,
SabuHi,
Kindly go through this sample code below:
"Create T_Head internal table with the required structure for the header
*func mod to download header and contents to the given path
call function 'GUI_DOWNLOAD'
exporting
write_field_separator = 'X'
filename = v_pathname "path entered by the user
tables
data_tab = t_head. "Header Internal table
refresh t_head.
clear t_head.
call function 'GUI_DOWNLOAD'
exporting
* BIN_FILESIZE =
filename = v_pathname
filetype = 'ASC'
append = 'X' "Here by giving 'X', header will be appended in the download int table
write_field_separator = 'X'
* HEADER = '00'
* TRUNC_TRAILING_BLANKS = ' '
* WRITE_LF = 'X'
* COL_SELECT = ' '
* COL_SELECT_MASK = ' '
* DAT_MODE = ' '
* CONFIRM_OVERWRITE = ' '
* NO_AUTH_CHECK = ' '
* CODEPAGE = ' '
* IGNORE_CERR = ABAP_TRUE
* REPLACEMENT = '#'
* WRITE_BOM = ' '
* TRUNC_TRAILING_BLANKS_EOL = 'X'
* WK1_N_FORMAT = ' '
* WK1_N_SIZE = ' '
* WK1_T_FORMAT = ' '
* WK1_T_SIZE = ' '
* IMPORTING
* FILELENGTH =
tables
data_tab = itab
* FIELDNAMES =
exceptions
file_write_error = 1
no_batch = 2
gui_refuse_filetransfer = 3
invalid_type = 4
no_authority = 5
unknown_error = 6
header_not_allowed = 7
separator_not_allowed = 8
filesize_not_allowed = 9
header_too_long = 10
dp_error_create = 11
dp_error_send = 12
dp_error_write = 13
unknown_dp_error = 14
access_denied = 15
dp_out_of_memory = 16
disk_full = 17
dp_timeout = 18
file_not_found = 19
dataprovider_exception = 20
control_flush_error = 21
others = 22
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
endif.
Hope it helps
Regards
Mansi -
What are internal table fields?
hi sdn,
Somebody asked me what are the internal table fields?hi,
data or varaibles that u declare inside the internal table are internal table fields
eg
BEGIN OF itab_final , "OCCURS 0 ,
mtart LIKE mara-mtart ,
wwghb1 LIKE t023d-wwghb , " DIVISION DESCRIPTION
wwgha LIKE t023d-wwgha , " MAJOR CATEGORY
wwghb LIKE t023d-wwghb , " MAJOR CATEGORY DESCRIPTION
wwgpa LIKE t023d-wwgpa , " CATEGORY
matkl LIKE mara-matkl , " MERCHANDISE CATEGORY
ean11 LIKE mara-ean11 , " International Article Number (EAN/UPC)
numtp LIKE mara-numtp ,
END OF itab_final .
mtart wwghb1 wwgha wwghb wwgpa matkl ean11 numtp . these are internal table fields
Regards,
pankaj -
Internal Table field description.
Hi everybody, I need in runtime the datails of a internal table field, for example the description of the field's data type. Do you know how can I get that information? Thanks and Regards.
Use RTTI .
[http://www.liveabap.com/index.php?abapid=11|http://www.liveabap.com/index.php?abapid=11] -
How to specify for a internal table field so that number of digits = 9
In if condition how can i specify that
if country = 'US'
then the account number should be equal to 9 digits only.
<removed_by_moderator>
Edited by: Julius Bussche on Aug 6, 2008 1:41 PMYou can set the internal table field to the biggest length possible, according to your requirements, and then work on something like the following. If the condition is met and you have to shorten the account number... try something similar to this:
DATA e TYPE string VALUE 'Test string'.
* I'm using 2 as an example here.
SHIFT e BY 2 PLACES RIGHT CIRCULAR.
SHIFT e BY 2 PLACES LEFT.
WRITE :/, e.
Avraham -
Time out error 1.6 million internal table fields are computed using FMs
Hi , All ...
The Report running fine in server with less 300 record but ...production server which has 1.6 million record it gives error as time-out error and takes hell amount of time.
Please suggest ugently ..
I have tried few things
Internal table having 1.6 lacs ... fields to compute .. i have token in a batch
loop at i_cinfo into s_cinfo from 1 to 100000.
and so on ...also applied all the performace related .. like indexs, work areas , deleting adjacent duplicates , for all entries ..wherever applicable.
Please Suggest .
Report is as below
REPORT ZUSOTCBD_CREDIT_REPORT .
TABLES : KNA1, " General Data Customer Master
KNB1, " Customer Master (Company Code)
KNC1, " Customer master (transaction figures)
KNKK, " Customer master credit management: Control area data
T009, " Fiscal Year Variants P
T009Y, " Shortened fiscal years in Asset Accounting P
T001, " Co. Codes
T001CM, " Permitted Credit Control Areas per Company Code
RF42B, " Structure to hold credit data.
RF035, " Structure to hold credit managment fields
RF02L, " Structure to hold credit data.
TRAS, " Interval for Days in Arrears P
T000CM. " Data for DSO calculation.
Types
TYPES:
BEGIN OF type_final,
string(50) TYPE c, " String Value for Title
END OF type_final.
data:wa_final TYPE type_final. " Work Area to hold Title Data
DATA: RASID TYPE RF035-RASID value 'R03N'. " For Days in interval
DATA: MONAT(2) TYPE N.
DATA: GJAHR TYPE KNC1-GJAHR.
DATA: LD_PERIODS(32) TYPE N
VALUE '01020304050607080910111213141516'.
DATA sytabix type sy-tabix.
DATA LAND TYPE KNA1-LAND1 VALUE 'US'. " Country Key
DATA: LD_PERIOD TYPE BSID-MONAT, " Fiscal Year Variant
LD_GJAHR TYPE KNC1-GJAHR,
LD_COUNTER TYPE SY-TABIX.
Internal Tables
Internal table to hold Title Data *
DATA:
i_final TYPE STANDARD TABLE OF type_final.
**Internal Table Permitted Credit Control Areas per Company Code
DATA: BEGIN OF TCMTAB OCCURS 10.
INCLUDE STRUCTURE T001CM.
DATA: END OF TCMTAB.
*Internal table to store Customer no.
DATA : BEGIN OF ICUST OCCURS 0,
KUNNR TYPE KNA1-KUNNR, " Customer No.
END OF ICUST.
DATA: BEGIN OF BUKTAB OCCURS 20,
KKBER LIKE T001-KKBER, " Credit Control Area
BUKRS LIKE T001-BUKRS, " Co. Code
WAERS LIKE T001-WAERS, " Currency
PERIV LIKE T001-PERIV, " Fiscal Year Variant
BUTXT LIKE T001-BUTXT,
END OF BUKTAB.
Internal Table to store Fiscal year Data .
DATA: BEGIN OF GJATAB OCCURS 5,
PERIV LIKE T001-PERIV, " Fiscal Year Variant
GJAHR LIKE KNC1-GJAHR, " Fiscal Year
MONAT LIKE T009-ANZBP, "
ANZBP LIKE T009-ANZBP, " Number of posting periods
END OF GJATAB.
*Main Output internal table to be used to store credit history Information
DATA : BEGIN OF I_CINFO occurs 0,
KUNNR TYPE KNB1-KUNNR, " Customer
KNKLI TYPE KNKK-KNKLI, " Customer's account number with credit limit reference
KKBER TYPE KNKK-KKBER, " Credit Control Area
CTLPC TYPE KNKK-CTLPC, " Risk Category
KLIMK TYPE KNKK-KLIMK, " Credit Limit
SBGRP TYPE KNKK-SBGRP, " Credit representative group for credit management
ERDAT TYPE KNKK-ERDAT, " Created On
DTREV TYPE KNKK-DTREV, " Last Internal Review
REVDB TYPE KNKK-REVDB, " Last External Review
SALDO TYPE RF42B-SALDO, " Balance
DSOIN TYPE RF02L-DSOIN, " DSO
H06SA TYPE RF035-H06SA, " Highest Balance at the end of 6 Months
H06JA TYPE RF035-H06JA, " Year highest Balance 6 Months
H06MO TYPE RF035-H06MO, " Month OF hihest Balance 6 Months
H12SA TYPE RF035-H12SA, " Highest Balance at the end of 12 Months
H12JA TYPE RF035-H12JA, " Year highest Balance 12 Months
H12MO TYPE RF035-H12MO, " Month OF hihest Balance 12 Months
UMP2U TYPE RF42B-UMP2U, " Sales from the current Year
UMP1U TYPE RF42B-UMP1U, " Sales from the Previous Year
SFAEL TYPE RF035-SFAEL, " Total Past Due Open Item
SFAE1 TYPE RF035-SFAE1, " Aging buckets 0-15
SFAE2 TYPE RF035-SFAE2, " Aging buckets 16-30
SFAE3 TYPE RF035-SFAE3, " Aging buckets 31-60
SFAE4 TYPE RF035-SFAE4, " Aging buckets 60-90
SFAE5 TYPE RF035-SFAE5, " Aging buckets Over 90
END Of I_CINFO.
DATA : BEGIN OF S_CINFO ,
KUNNR TYPE KNB1-KUNNR, " Customer
KNKLI TYPE KNKK-KNKLI, " Customer's account number with credit limit reference
KKBER TYPE KNKK-KKBER, " Credit Control Area
CTLPC TYPE KNKK-CTLPC, " Risk Category
KLIMK TYPE KNKK-KLIMK, " Credit Limit
SBGRP TYPE KNKK-SBGRP, " Credit representative group for credit management
ERDAT TYPE KNKK-ERDAT, " Created On
DTREV TYPE KNKK-DTREV, " Last Internal Review
REVDB TYPE KNKK-REVDB, " Last External Review
SALDO TYPE RF42B-SALDO, " Balance
DSOIN TYPE RF02L-DSOIN, " DSO
H06SA TYPE RF035-H06SA, " Highest Balance at the end of 6 Months
H06JA TYPE RF035-H06JA, " Year highest Balance 6 Months
H06MO TYPE RF035-H06MO, " Month OF hihest Balance 6 Months
H12SA TYPE RF035-H12SA, " Highest Balance at the end of 12 Months
H12JA TYPE RF035-H12JA, " Year highest Balance 12 Months
H12MO TYPE RF035-H12MO, " Month OF hihest Balance 12 Months
UMP2U TYPE RF42B-UMP2U, " Sales from the current Year
UMP1U TYPE RF42B-UMP1U, " Sales from the Previous Year
SFAEL TYPE RF035-SFAEL, " Total Past Due Open Item
SFAE1 TYPE RF035-SFAE1, " Aging buckets 0-15
SFAE2 TYPE RF035-SFAE2, " Aging buckets 16-30
SFAE3 TYPE RF035-SFAE3, " Aging buckets 31-60
SFAE4 TYPE RF035-SFAE4, " Aging buckets 60-90
SFAE5 TYPE RF035-SFAE5, " Aging buckets Over 90
END Of s_cinfo.
*Internal table to hold month-wise balance.
DATA: BEGIN OF SALTAB OCCURS 12,
LNUMM(2) TYPE N, " Month
SALDO LIKE RF42B-SALDO, " Balance
END OF SALTAB.
*Internal table used for computing the Balance fields
DATA: BEGIN OF SALDO,
UML01 LIKE KNC1-UM01S,
UML02 LIKE KNC1-UM01S,
UML03 LIKE KNC1-UM01S,
UML04 LIKE KNC1-UM01S,
UML05 LIKE KNC1-UM01S,
UML06 LIKE KNC1-UM01S,
UML07 LIKE KNC1-UM01S,
UML08 LIKE KNC1-UM01S,
UML09 LIKE KNC1-UM01S,
UML10 LIKE KNC1-UM01S,
UML11 LIKE KNC1-UM01S,
UML12 LIKE KNC1-UM01S,
END OF SALDO.
Structure to hold Bal fields ------ -------
DATA: BEGIN OF SKNKK,
KUNNR LIKE KNA1-KUNNR, " Customer Number 1: Debitor
KONTO LIKE KNKK-KUNNR,
SFAE1 LIKE RF035-SFAE1, " Aging buckets 0-15
SFAE2 LIKE RF035-SFAE2, " Aging buckets 16-30
SFAE3 LIKE RF035-SFAE3, " Aging buckets 30-60
SFAE4 LIKE RF035-SFAE4, " Aging buckets 60-90
SFAE5 LIKE RF035-SFAE5, " Aging buckets Over 90
SFAEL LIKE RF035-SFAEL, " Total Due of Items
UML01 LIKE KNC1-UM01S,
UML02 LIKE KNC1-UM01S,
UML03 LIKE KNC1-UM01S,
UML04 LIKE KNC1-UM01S,
UML05 LIKE KNC1-UM01S,
UML06 LIKE KNC1-UM01S,
UML07 LIKE KNC1-UM01S,
UML08 LIKE KNC1-UM01S,
UML09 LIKE KNC1-UM01S,
UML10 LIKE KNC1-UM01S,
UML11 LIKE KNC1-UM01S,
UML12 LIKE KNC1-UM01S,
UMP1U LIKE RF42B-UMP1U, " Sales from the Previous Year
UMP2U LIKE RF42B-UMP2U, " Sales from the current Year
SALDO LIKE RF42B-SALDO, " Balance
END OF SKNKK.
DATA : BEGIN OF ICUST1 OCCURS 0,
KUNNR TYPE KNA1-KUNNR, "For Customer Filter.
END OF ICUST1.
**Internal table to hold fiscal varriants
DATA: BEGIN OF LT_PERIODS OCCURS 12,
PERIOD LIKE BSID-MONAT,
GJAHR LIKE KNC1-GJAHR,
END OF LT_PERIODS.
**Constants
constants : BUKRS1 TYPE KNB1-BUKRS VALUE '1000',
BUKRS2 TYPE KNB1-BUKRS VALUE '1031',
Recs Type i value '200',
B_count type i value '2'.
INITIALIZATION
INITIALIZATION.
IF RASID IS INITIAL.
SELECT * FROM TRAS.
EXIT.
ENDSELECT.
IF SY-SUBRC = 0.
RASID = TRAS-RASID.
ENDIF.
ENDIF.
SELECTION-SCREEN
parameters : p_path type rlgrap-filename default 'C:\Documents and Settings\C890971\Desktop\Credit_history.XLS'.
Start of selection processing
START-OF-SELECTION.
**Get Customers for Co. Code 1000 & 1031.
PERFORM GET_CUST.
Get / Compute Credit Information data for Company Codes 1000 & 1031.
PERFORM GET_CREDIT_DATA.
End of selection processing
*END-OF-SELECTION.
Listing Credit History Data
PERFORM DOWNLOAD_CREDIT_DATA.
S U B R O U T I N E S
*& Form GET_CUST
text
--> p1 text
<-- p2 text
FORM GET_CUST .
Get US only Customers.
Refresh icust.
Select kunnr from kna1 appending table icust
where Land1 = land.
**Delete duplicate records
Delete Adjacent duplicates from icust comparing kunnr.
if icust[] is not initial.
Limit the selection some more to Co. Code 1000 & 1031
As join will cost overhead as compared.
Select kunnr from knb1 into table icust1
for all entries in icust
where kunnr = icust-kunnr
and bukrs = bukrs1
OR bukrs = bukrs2.
**Delete duplicate records
Delete Adjacent duplicates from icust1 comparing kunnr.
endif.
**Free memory.
Free icust.
Credit Control Area
select * from T001CM into table TCMTAB
where bukrs = bukrs1 OR
bukrs = bukrs2.
ENDFORM. " GET_CUST
*& Form GET_CREDIT_DATA
text
--> p1 text
<-- p2 text
FORM GET_CREDIT_DATA .
DATA : L_TEXT(60) TYPE C ,
Ltext1(50) type C value 'Computing Credit-History Data For',
Ltext2(10) type C value 'Customers',
L_PCT type i value '10',
L_recs type i,
l_batch_recs type i,
l_s_rec type i value 1,
l_recs1(7) type N.
***Fetch data from KNKK table
PERFORM GET_KNKK_DATA .
***Computing Crredit Fields
**Number of Customers For whom Deatils needed.
Describe table I_CINFO lines l_recs.
l_recs1 = l_recs.
Concatenate Ltext1 l_recs1 Ltext2 into l_text separated by ' '.
PERFORM GET_PGRESS_INDICATOR USING l_text l_pct.
***If records are more than 200000, should be processed batch-wise
If l_recs > recs.
l_batch_recs = abs( l_recs / b_count ).
Do b_count times.
loop at i_cinfo INTO S_CINFO from l_S_REC to l_batch_recs.
**Remember the row
sytabix = sy-tabix.
**Compute DSO
PERFORM GET_DSO_FIELD .
Compute rest credit history data.
PERFORM COMPUTE_SFIELDS.
endloop.
l_S_REC = l_S_REC + l_batch_recs.
l_batch_recs = l_batch_recs + l_batch_recs.
IF l_batch_recs ge l_recs.
l_batch_recs = l_recs.
eNDIF.
Commit up to here to release the DB locks.
Commit work.
enddo.
else.
loop at i_cinfo INTO S_CINFO.
**Remember the row
sytabix = sy-tabix.
**Compute DSO
PERFORM GET_DSO_FIELD .
Compute rest credit history data.
PERFORM COMPUTE_SFIELDS.
endloop.
Endif.
ENDFORM. " GET_CREDIT_DATA
*& Form GET_KNKK_DATA
text
-->P_ICUST_KUNNR text
FORM GET_KNKK_DATA .
if icust1[] is not initial.
SELECT KUNNR KNKLI KKBER CTLPC KLIMK
SBGRP ERDAT DTREV REVDB
from KNKK into corresponding fields of table I_Cinfo
for all entries in icust1
where kunnr = icust1-kunnr.
Delete Adjacent duplicates from i_cinfo comparing kunnr.
endif.
**Free Memory for internal table icust1.
Free icust1.
ENDFORM. " GET_KNKK_DATA
**& Form GET_DSO_FIELD
text
--> p1 text
<-- p2 text
FORM GET_DSO_FIELD .
***Determine DSO Parameter
PERFORM DSO_PARAMETER.
***Compute DSO
CALL FUNCTION 'CUSTOMER_DSO_CALCULATION'
EXPORTING
I_KKBER = s_cinfo-kkber
I_KUNNR = s_cinfo-kunnr
I_ANZBUPER = T000CM-DSOPP
I_XCHILDS = T000CM-DSOCH
I_ACTBALANCE = T000CM-DSOAB
IMPORTING
E_DSOIN = RF02L-DSOIN
EXCEPTIONS
ERROR_MESSAGE = 1.
ENDFORM. " GET_DSO_FIELD
*& Form DSO_PARAMETER
text
--> p1 text
<-- p2 text
FORM DSO_PARAMETER.
IF T000CM-DSOPP IS INITIAL.
SELECT SINGLE * FROM T000CM.
IF SY-SUBRC EQ 0.
IF T000CM-DSOPP IS INITIAL.
T000CM-DSOPP = '003'.
ENDIF.
ELSE.
T000CM-DSOPP = '003'.
T000CM-DSOCH = ' '.
T000CM-DSOAB = 'X'.
ENDIF.
ENDIF.
ENDFORM. " DSO_PARAMETER
--> p1 text
<-- p2 text
FORM PERIODE_ERMITTELN_EXC USING
P03_BUDAT LIKE SYST-DATUM
P03_GJAHR LIKE KNC1-GJAHR
P03_MONAT LIKE MONAT.
CALL FUNCTION 'FI_PERIOD_DETERMINE'
EXPORTING
I_BUDAT = P03_BUDAT
I_PERIV = T001-PERIV
I_BUKRS = T001-BUKRS
I_GJAHR = P03_GJAHR
I_MONAT = P03_MONAT
IMPORTING
E_GJAHR = P03_GJAHR
E_MONAT = P03_MONAT
EXCEPTIONS
ERROR_MESSAGE = 1.
ENDFORM. "PERIODE_ERMITTELN_EXC
*& Form COMPUTE_SFIELDS
text
--> p1 text
<-- p2 text
FORM COMPUTE_SFIELDS .
**Compute Balance
PERFORM GET_SFIELDS .
S_CINFO-DSOIN = RF02L-DSOIN.
S_CINFO-SALDO = RF035-SALDO.
S_CINFO-H06SA = RF035-H06SA.
S_CINFO-H06JA = RF035-H06JA.
S_CINFO-H06MO = RF035-H06MO.
S_CINFO-H12SA = RF035-H12SA.
S_CINFO-H12JA = RF035-H12JA.
S_CINFO-H12MO = RF035-H12MO.
S_CINFO-UMP2U = RF42B-UMP2U.
S_CINFO-UMP1U = RF42B-UMP1U.
S_CINFO-SFAEL = RF035-SFAEL.
S_CINFO-SFAE1 = RF035-SFAE1.
S_CINFO-SFAE2 = RF035-SFAE2.
S_CINFO-SFAE3 = RF035-SFAE3.
S_CINFO-SFAE4 = RF035-SFAE4.
S_CINFO-SFAE5 = RF035-SFAE5.
modify..
MODIFY I_CINFO FROM S_CINFO INDEX sytabix.
CLEAR: S_CINFO,RF035,RF02L, RF42B.
ENDFORM. " COMPUTE_SFIELDS
text
-->P_C_INFO_KUNNR text
FORM GET_CUST_BAL_INFO.
LOOP AT TCMTAB.
CALL FUNCTION 'FI_COMPANY_CODE_DATA'
EXPORTING
I_BUKRS = TCMTAB-BUKRS
IMPORTING
E_T001 = T001
EXCEPTIONS
ERROR_MESSAGE = 1.
IF SY-SUBRC = 0.
MOVE-CORRESPONDING T001 TO BUKTAB.
BUKTAB-KKBER = TCMTAB-KKBER.
COLLECT BUKTAB.
ENDIF.
ENDLOOP.
LOOP AT BUKTAB WHERE PERIV NE SPACE.
GJATAB-PERIV = BUKTAB-PERIV.
COLLECT GJATAB.
ENDLOOP.
CLEAR: MONAT.
LOOP AT GJATAB.
T001-PERIV = GJATAB-PERIV.
CLEAR: GJAHR, MONAT.
PERFORM PERIODE_ERMITTELN_EXC USING SY-DATLO GJAHR MONAT.
CHECK SY-SUBRC = 0.
GJATAB-GJAHR = GJAHR.
GJATAB-MONAT = MONAT.
SELECT SINGLE * FROM T009 WHERE PERIV = GJATAB-PERIV.
IF SY-SUBRC = 0.
GJATAB-ANZBP = T009-ANZBP.
ENDIF.
MODIFY GJATAB.
ENDLOOP.
LOOP AT BUKTAB.
CHECK NOT ( BUKTAB-PERIV IS INITIAL ).
READ TABLE GJATAB WITH KEY BUKTAB-PERIV.
CHECK SY-SUBRC = 0
AND NOT ( GJATAB-GJAHR IS INITIAL ).
CALL FUNCTION 'CUSTOMER_BALANCE'
EXPORTING
KUNNR = S_cinfo-kunnr
BUKRS = BUKTAB-BUKRS
GJAHR = GJATAB-GJAHR
MONAT = GJATAB-MONAT
PERIV = GJATAB-PERIV
ANZBP = GJATAB-ANZBP
XH6MON = 'X'
XH12MON = 'X'
IMPORTING
UMP2U = RF42B-UMP2U
VMP2U = RF42B-UMP1U
SALDO = RF035-SALDO
UML01 = SALDO-UML01
UML02 = SALDO-UML02
UML03 = SALDO-UML03
UML04 = SALDO-UML04
UML05 = SALDO-UML05
UML06 = SALDO-UML06
UML07 = SALDO-UML07
UML08 = SALDO-UML08
UML09 = SALDO-UML09
UML10 = SALDO-UML10
UML11 = SALDO-UML11
UML12 = SALDO-UML12
EXCEPTIONS
NO_BALANCE = 4.
IF SY-SUBRC = 0.
SKNKK-UMP1U = SKNKK-UMP1U + RF42B-UMP1U.
SKNKK-UMP2U = SKNKK-UMP2U + RF42B-UMP2U.
SKNKK-SALDO = SKNKK-SALDO + RF035-SALDO.
SKNKK-UML01 = SKNKK-UML01 + SALDO-UML01.
SKNKK-UML02 = SKNKK-UML02 + SALDO-UML02.
SKNKK-UML03 = SKNKK-UML03 + SALDO-UML03.
SKNKK-UML04 = SKNKK-UML04 + SALDO-UML04.
SKNKK-UML05 = SKNKK-UML05 + SALDO-UML05.
SKNKK-UML06 = SKNKK-UML06 + SALDO-UML06.
SKNKK-UML07 = SKNKK-UML07 + SALDO-UML07.
SKNKK-UML08 = SKNKK-UML08 + SALDO-UML08.
SKNKK-UML09 = SKNKK-UML09 + SALDO-UML09.
SKNKK-UML10 = SKNKK-UML10 + SALDO-UML10.
SKNKK-UML11 = SKNKK-UML11 + SALDO-UML11.
SKNKK-UML12 = SKNKK-UML12 + SALDO-UML12.
ENDIF.
ENDLOOP.
ENDFORM. "
*& Form GET_SFIELDS
text
--> p1 text
<-- p2 text
FORM GET_SFIELDS .
sknkk-kunnr = S_CINFO-KUNNR.
**Clear target to store computed values
CLEAR: RF035.
**Compute Balance fields
PERFORM GET_CUST_BAL_INFO.
REFRESH: SALTAB.
SALTAB-LNUMM = '01'. SALTAB-SALDO = SKNKK-UML01. APPEND SALTAB.
SALTAB-LNUMM = '02'. SALTAB-SALDO = SKNKK-UML02. APPEND SALTAB.
SALTAB-LNUMM = '03'. SALTAB-SALDO = SKNKK-UML03. APPEND SALTAB.
SALTAB-LNUMM = '04'. SALTAB-SALDO = SKNKK-UML04. APPEND SALTAB.
SALTAB-LNUMM = '05'. SALTAB-SALDO = SKNKK-UML05. APPEND SALTAB.
SALTAB-LNUMM = '06'. SALTAB-SALDO = SKNKK-UML06. APPEND SALTAB.
SALTAB-LNUMM = '07'. SALTAB-SALDO = SKNKK-UML07. APPEND SALTAB.
SALTAB-LNUMM = '08'. SALTAB-SALDO = SKNKK-UML08. APPEND SALTAB.
SALTAB-LNUMM = '09'. SALTAB-SALDO = SKNKK-UML09. APPEND SALTAB.
SALTAB-LNUMM = '10'. SALTAB-SALDO = SKNKK-UML10. APPEND SALTAB.
SALTAB-LNUMM = '11'. SALTAB-SALDO = SKNKK-UML11. APPEND SALTAB.
SALTAB-LNUMM = '12'. SALTAB-SALDO = SKNKK-UML12. APPEND SALTAB.
READ TABLE SALTAB INDEX 1.
RF035-H06SA = SALTAB-SALDO.
RF035-H06MO = SALTAB-LNUMM.
RF035-H12SA = SALTAB-SALDO.
RF035-H12MO = SALTAB-LNUMM.
------ SALTAB ---------------------------------------------
LOOP AT SALTAB.
IF SALTAB-SALDO > RF035-H06SA
AND SY-TABIX < 7.
RF035-H06SA = SALTAB-SALDO.
RF035-H06MO = SALTAB-LNUMM.
ENDIF.
IF SALTAB-SALDO > RF035-H12SA
AND SY-TABIX < 13.
RF035-H12SA = SALTAB-SALDO.
RF035-H12MO = SALTAB-LNUMM.
ENDIF.
ENDLOOP.
------ Period--------------------
REFRESH LT_PERIODS.
CLEAR LD_COUNTER.
READ TABLE BUKTAB INDEX 1.
IF SY-SUBRC = 0.
READ TABLE GJATAB WITH KEY BUKTAB-PERIV.
DO GJATAB-MONAT TIMES
VARYING LD_PERIOD FROM LD_PERIODS(2) NEXT LD_PERIODS+2(2)
RANGE LD_PERIODS.
LT_PERIODS-GJAHR = GJATAB-GJAHR.
LT_PERIODS-PERIOD = LD_PERIOD.
LD_COUNTER = LD_COUNTER + 1.
APPEND LT_PERIODS.
ENDDO.
IF LD_COUNTER LT 12.
LD_GJAHR = GJATAB-GJAHR - 1.
CLEAR T009Y.
SELECT SINGLE * FROM T009Y WHERE PERIV = GJATAB-PERIV
AND GJAHR = LD_GJAHR.
DO GJATAB-ANZBP TIMES
VARYING LD_PERIOD FROM LD_PERIODS(2) NEXT LD_PERIODS+2(2)
RANGE LD_PERIODS.
IF T009Y-ANZBP > 0.
CHECK SY-INDEX <= T009Y-ANZBP.
ENDIF.
LD_COUNTER = LD_COUNTER + 1.
LT_PERIODS-GJAHR = LD_GJAHR.
LT_PERIODS-PERIOD = LD_PERIOD.
APPEND LT_PERIODS.
ENDDO.
ENDIF.
IF LD_COUNTER LT 12.
LD_GJAHR = LD_GJAHR - 1.
DO GJATAB-ANZBP TIMES
VARYING LD_PERIOD FROM LD_PERIODS(2) NEXT LD_PERIODS+2(2)
RANGE LD_PERIODS.
LD_COUNTER = LD_COUNTER + 1.
LT_PERIODS-GJAHR = LD_GJAHR.
LT_PERIODS-PERIOD = LD_PERIOD.
APPEND LT_PERIODS.
ENDDO.
ENDIF.
SORT LT_PERIODS BY GJAHR ASCENDING PERIOD ASCENDING.
LD_COUNTER = LD_COUNTER - 12.
DO LD_COUNTER TIMES.
DELETE LT_PERIODS INDEX 1.
ENDDO.
SORT LT_PERIODS BY GJAHR DESCENDING PERIOD DESCENDING.
READ TABLE LT_PERIODS INDEX RF035-H06MO.
RF035-H06MO = LT_PERIODS-PERIOD.
RF035-H06JA = LT_PERIODS-GJAHR.
READ TABLE LT_PERIODS INDEX RF035-H12MO.
RF035-H12MO = LT_PERIODS-PERIOD.
RF035-H12JA = LT_PERIODS-GJAHR.
ENDIF.
**Compute Due Dates fields
PERFORM GET_AGING_BUCKETS .
RF035-SFAE1 = SKNKK-SFAE1.
RF035-SFAE2 = SKNKK-SFAE2.
RF035-SFAE3 = SKNKK-SFAE3.
RF035-SFAE4 = SKNKK-SFAE4 .
RF035-SFAE5 = SKNKK-SFAE5.
ENDLOOP.
ENDFORM. " GET_BALANCE_SFIELDS
*& Form GET_AGING_BUCKETS
text
--> p1 text
<-- p2 text
FORM GET_AGING_BUCKETS .
DATA: BEGIN OF LT_BUKRS OCCURS 0,
BUKRS LIKE T001-BUKRS,
END OF LT_BUKRS.
DATA: BEGIN OF LT_BUKTAB OCCURS 0,
BUKRS LIKE T001-BUKRS,
WAERS LIKE T001-WAERS,
KKBER LIKE T014-KKBER,
END OF LT_BUKTAB.
DATA: LD_LINES LIKE SY-TABIX.
*...performance optimization: for more than one company codes check....*
*...if balances exist and avoid selection of open items, if they don't.*
*...exist..............................................................*
REFRESH LT_BUKRS.
REFRESH LT_BUKTAB.
DESCRIBE TABLE BUKTAB LINES LD_LINES.
IF LD_LINES GT 1.
SELECT DISTINCT BUKRS APPENDING CORRESPONDING FIELDS
OF TABLE LT_BUKRS
FROM KNC1 FOR ALL ENTRIES IN BUKTAB
WHERE BUKRS = BUKTAB-BUKRS AND
KUNNR = Sknkk-KUNNR.
SELECT DISTINCT BUKRS APPENDING CORRESPONDING FIELDS
OF TABLE LT_BUKRS
FROM KNC3 FOR ALL ENTRIES IN BUKTAB
WHERE BUKRS = BUKTAB-BUKRS AND
KUNNR = Sknkk-KUNNR.
SORT LT_BUKRS.
DELETE ADJACENT DUPLICATES FROM LT_BUKRS.
LOOP AT LT_BUKRS.
LOOP AT BUKTAB WHERE BUKRS = LT_BUKRS-BUKRS.
MOVE-CORRESPONDING BUKTAB TO LT_BUKTAB.
APPEND LT_BUKTAB.
ENDLOOP.
ENDLOOP.
ELSE.
READ TABLE BUKTAB INDEX 1.
MOVE-CORRESPONDING BUKTAB TO LT_BUKTAB.
APPEND LT_BUKTAB.
ENDIF.
*...process company codes for customer given by interface..........*
LOOP AT LT_BUKTAB WHERE KKBER = s_cinfo-KKBER.
CALL FUNCTION 'CUSTOMER_DUE_DATE_ANALYSIS'
EXPORTING BUKRS = LT_BUKTAB-BUKRS
KKBER = ' '
KKBER = s_cinfo-KKBER
KUNNR = Sknkk-KUNNR
RASID = RASID
IMPORTING SFAE1 = RF035-SFAE1
SFAE2 = RF035-SFAE2
SFAE3 = RF035-SFAE3
SFAE4 = RF035-SFAE4
SFAE5 = RF035-SFAE5
SFAEL = RF035-SFAEL
EXCEPTIONS NO_OPEN_ITEMS = 4.
IF SY-SUBRC = 0.
*-- RF035 -
SKNKK-SFAE1 = SKNKK-SFAE1 + RF035-SFAE1.
SKNKK-SFAE2 = SKNKK-SFAE2 + RF035-SFAE2.
SKNKK-SFAE3 = SKNKK-SFAE3 + RF035-SFAE3.
SKNKK-SFAE4 = SKNKK-SFAE4 + RF035-SFAE4.
SKNKK-SFAE5 = SKNKK-SFAE5 + RF035-SFAE5.
SKNKK-SFAE5 = SKNKK-SFAE5 + RF035-SFAE5.
SKNKK-SFAEL = SKNKK-SFAEL + RF035-SFAEL.
ENDIF.
ENDLOOP.
ENDFORM. " GET_AGING_BUCKETS
*& Form header
This Subroutine gets data for displaying title *
There are no interface parameters to be passed to this subroutine. *
FORM header .
wa_final-string = text-000. APPEND wa_final TO i_final.
wa_final-string = text-001. APPEND wa_final TO i_final.
wa_final-string = text-002. APPEND wa_final TO i_final.
wa_final-string = text-003. APPEND wa_final TO i_final.
wa_final-string = text-004. APPEND wa_final TO i_final.
wa_final-string = text-005. APPEND wa_final TO i_final.
wa_final-string = text-006. APPEND wa_final TO i_final.
wa_final-string = text-007. APPEND wa_final TO i_final.
wa_final-string = text-008. APPEND wa_final TO i_final.
wa_final-string = text-009. APPEND wa_final TO i_final.
wa_final-string = text-010. APPEND wa_final TO i_final.
wa_final-string = text-011. APPEND wa_final TO i_final.
wa_final-string = text-012. APPEND wa_final TO i_final.
wa_final-string = text-013. APPEND wa_final TO i_final.
wa_final-string = text-014. APPEND wa_final TO i_final.
wa_final-string = text-015. APPEND wa_final TO i_final.
wa_final-string = text-016. APPEND wa_final TO i_final.
wa_final-string = text-017. APPEND wa_final TO i_final.
wa_final-string = text-018. APPEND wa_final TO i_final.
wa_final-string = text-019. APPEND wa_final TO i_final.
wa_final-string = text-020. APPEND wa_final TO i_final.
wa_final-string = text-021. APPEND wa_final TO i_final.
wa_final-string = text-022. APPEND wa_final TO i_final.
wa_final-string = text-023. APPEND wa_final TO i_final.
wa_final-string = text-024. APPEND wa_final TO i_final.
ENDFORM. " header
*& Form DOWNLOADCREDITDATA
text
-->P_P_PATH text
FORM DOWNLOADCREDITDATA USING P_PATH.
DATA:
lw_file2 TYPE string . " File Path
lw_file2 = p_PATH.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
BIN_FILESIZE = BIN_FILESIZE
filename = lw_file2
filetype = 'DBF'
APPEND = ' '
write_field_separator = ' '
HEADER = '00'
TRUNC_TRAILING_BLANKS = 'X'
WRITE_LF = 'X'
COL_SELECT = 'X'
COL_SELECT_MASK = ' '
DAT_MODE = 'X'
CONFIRM_OVERWRITE = ' '
NO_AUTH_CHECK = ' '
CODEPAGE = ' '
IGNORE_CERR = ABAP_TRUE
REPLACEMENT = '#'
WRITE_BOM = ' '
TRUNC_TRAILING_BLANKS_EOL = 'X'
WK1_N_FORMAT = '0'
WK1_N_SIZE = ' '
WK1_T_FORMAT = ' '
WK1_T_SIZE = ' '
IMPORTING
FILELENGTH = FILELENGTH
TABLES
data_tab = I_CINFO
fieldnames = i_final
EXCEPTIONS
file_write_error = 1
no_batch = 2
gui_refuse_filetransfer = 3
invalid_type = 4
no_authority = 5
unknown_error = 6
header_not_allowed = 7
separator_not_allowed = 8
filesize_not_allowed = 9
header_too_long = 10
dp_error_create = 11
dp_error_send = 12
dp_error_write = 13
unknown_dp_error = 14
access_denied = 15
dp_out_of_memory = 16
disk_full = 17
dp_timeout = 18
file_not_found = 19
dataprovider_exception = 20
control_flush_error = 21
IF sy-subrc <> 0.
Messege
ENDIF. " IF sy-subrc EQ 0
ENDFORM. " DOWNLOADCREDITDATA
*& Form DOWNLOAD_CREDIT_DATA
text
--> p1 text
<-- p2 text
FORM DOWNLOAD_CREDIT_DATA .
PERFORM HEADER.
PERFORM DOWNLOADCREDITDATA USING P_PATH.
ENDFORM. " DOWNLOAD_CREDIT_DATA
*& Form GET_PGRESS_INDICATOR
text
-->P_L_TEXT text
-->P_L_PCT text
FORM GET_PGRESS_INDICATOR USING L_TEXT
L_PCT.
CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
EXPORTING
PERCENTAGE = l_pct
TEXT = l_TEXT.
ENDFORM. " GET_PGRESS_INDICATORIf you are just Downloading to a Flat file then why dont you have logic in place for the program to dump the data read into the file to that point depending on any criteria like accounts or customer then clear the internal table and run it in the back ground.
try to use cursor to read the records from the table which will make it a bit more efficient than plain select stement. -
Totals for the internal table field in alv
Hi Gurus,
I have an issue in displaying the totals in alv.
I have an internal table with the three fields like below.
scrap_code_001 like afru-xmnga, " Scrap Reason Qty.
scrap_code_002 like afru-xmnga, " Scrap Reason Qty.
scrap_code_003 like afru-xmnga, " Scrap Reason Qty.
In the output table which i am passing to the fieldcatlog is having the three above fields with values 10,3,4 respectively.
I am looping at the internal table
loop at gt_grund.
gv_tabix = sy-tabix.
i_fieldcat-no_zero = gc_x.
i_fieldcat-do_sum = gc_x.
perform assign_alv_qty_format.
if gt_grund-grund is initial.
gt_grund = 'NONE'.
gv_text = gt_grund.
else.
gv_text = gt_grund-grdtx.
endif.
gv_tabixn = gv_tabix.
gv_scrap_code+11(03) = gv_tabixn.
gv_fieldname = gv_scrap_code.
translate gv_fieldname to upper case.
perform bild_fieldcat using
gv_fieldname 'GT_REPORT' 'AFRU' gv_text 'QUAN' '12' ' ' .
endif.
endloop.
But in the output I am getting the totals but it displays totals for all the three columns as 17,17,17 (summing 10,3,4).
How do I display total as 10,3,4 for each column separately.
I appreciate you help and award points for the answerHi,
Please check if value fields i_fieldcat-ref_fieldname and i_fieldcat-ref_tabname regard to numc or curr type.
EX: i_fieldcat-ref_fieldname = 'WRBTR'
I_fieldcat-ref_tabname = 'BSEG'.
Regards,
Fernando -
How to populate internal table field with text data?
Hello Experts,
I was able to load text file to a internal table but data is not populating each field. Can someone help me how to populate each field of internal table from text file?
Here is the text file:
io_name, io_type, io_txsht, io_txlng, io_datatype, io_length
ZEA_IO1, CHA, IO Test, IO Test 1, CHAR, 20
ZEA_IO2, CHA, IO Test, IO Test 2, CHAR, 20
Here is the Code:
*& Report ZAS_BAPI_TEST *
*& InfoObject Creation through BAPI.
*& Read the Text file, call a BAPI to create InfoObjects. *
*& Text file will hold the Info Object Structure. Text file will be *
*& located either work station or local PC.
*& Step 1. Create internal table to hold InfoObject structure *
*& Step 2. Retrieve/Load text file into Internal Table structure *
*& Step 3. Call BAPI Function to Create IO *
*& Step 4. Call BAPI Function to Activate IO *
REPORT ZAS_BAPI_TEST .
Make data separator a comma
CONSTANTS: gc_tab TYPE c VALUE ','.
Declaring Internal table for creating InfoObject
DATA: p_file TYPE string.
DATA: BEGIN OF itab-bapi OCCURS 0,
io_name like BAPI6108-infoobject,
io_type like BAPI6108-type,
io_txsht like BAPI6108-textshort,
io_txlng like BAPI6108-textlong,
io_datatype like BAPI6108-datatp,
io_length like BAPI6108-intlen,
END OF itab-bapi.
DATA ibapi LIKE STANDARD TABLE OF itab-bapi.
PARAMETERS: sel_file(1500) TYPE c default ' ' OBLIGATORY LOWER CASE.
PUT THE TEXT FILE PATH TO P_FILE
p_file = sel_file.
Copy the file from the workstation to the server ****
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = p_file
FILETYPE = 'ASC'
HAS_FIELD_SEPARATOR = SPACE
HEADER_LENGTH = 0
DAT_MODE = SPACE
CODEPAGE = SPACE
IGNORE_CERR = ABAP_TRUE
REPLACEMENT = '#'
READ_BY_LINE = 'X'
IMPORTING
FILELENGTH =
HEADER =
TABLES
data_tab = itab-bapi[]
EXCEPTIONS
file_open_error = 1
file_read_error = 2
no_batch = 3
gui_refuse_filetransfer = 4
invalid_type = 5
no_authority = 6
unknown_error = 7
bad_data_format = 8
header_not_allowed = 9
separator_not_allowed = 10
header_too_long = 11
unknown_dp_error = 12
access_denied = 13
dp_out_of_memory = 14
disk_full = 15
dp_timeout = 16
not_supported_by_gui = 17
error_no_gui = 18
OTHERS = 19.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
MESSAGE e012(zea_spms) WITH 'Method' 'GUI_UPLOAD' sy-subrc.
&1 &2 issued return code &3
ELSE.
pit_data[] = lit_data[].
ENDIF.
ENDIF.
loop at itab-bapi.
write: /5 itab-bapi-io_name,
20 itab-bapi-io_type,
30 itab-bapi-io_txsht,
50 itab-bapi-io_txlng,
75 itab-bapi-io_datatype,
85 itab-bapi-io_length.
endloop.
SELECT THE LOCATION FOR TEXT FILE
AT SELECTION-SCREEN ON VALUE-REQUEST FOR sel_file.
CALL FUNCTION 'WS_FILENAME_GET'
EXPORTING
def_filename = ''
def_path = 'C:\'
mask = ',Documentos de texto (*.txt), *.txt.'
mode = ''
IMPORTING
filename = p_file
EXCEPTIONS
inv_winsys = 1
no_batch = 2
selection_cancel = 3
selection_error = 4
OTHERS = 5.
find '.txt' IN p_file.
if sy-subrc <> 0.
concatenate p_file '.txt' into sel_file.
else.
sel_file = p_file.
endif.
Create InfoObject through BAPI Function
*CALL FUNCTION 'BAPI_IOBJ_CREATE'.
*IMPORTING
VALUE(DETAILS) LIKE BAPI6108 STRUCTURE BAPI6108
*EXPORTING
VALUE(INFOOBJECT) LIKE BAPI6108-INFOOBJECT
VALUE(RETURN) LIKE BAPIRET2 STRUCTURE BAPIRET2
TABLES
COMPOUNDS STRUCTURE BAPI6108CM OPTIONAL
ATTRIBUTES STRUCTURE BAPI6108AT OPTIONAL
NAVIGATIONATTRIBUTES STRUCTURE BAPI6108AN OPTIONAL
ATRNAVINFOPROVIDER STRUCTURE BAPI6108NP OPTIONAL
HIERARCHYCHARACTERISTICS STRUCTURE BAPI6108HC OPTIONAL
ELIMINATION STRUCTURE BAPI6108IE OPTIONAL
RETURNTABLE STRUCTURE BAPIRET2 OPTIONAL
Activate InfoObject through BAPI Function
CALL FUNCTION 'BAPI_IOBJ_ACTIVATE_MULTIPLE'
*ENDFORM. " RETRIEVE_DATASET
I appreciate your help.
Regards,
MauI have used tab delimited file.
Here are file contents
io_name io_type io_txsht io_txlng io_datatype io_length
ZEA_IO1 CHA IO Test IO Test 1 CHAR 20
ZEA_IO2 CHA IO Test IO Test 2 CHAR 20
And here is program used
*& Report ZAS_BAPI_TEST *
*& InfoObject Creation through BAPI.
*& Read the Text file, call a BAPI to create InfoObjects. *
*& Text file will hold the Info Object Structure. Text file will be *
*& located either work station or local PC.
*& Step 1. Create internal table to hold InfoObject structure *
*& Step 2. Retrieve/Load text file into Internal Table structure *
*& Step 3. Call BAPI Function to Create IO *
*& Step 4. Call BAPI Function to Activate IO *
REPORT ZAS_BAPI_TEST .
Make data separator a comma
CONSTANTS: gc_tab TYPE c VALUE ','.
Declaring Internal table for creating InfoObject
DATA: p_file TYPE string.
DATA: BEGIN OF itab-bapi OCCURS 0,
io_name like BAPI6108-infoobject,
io_type like BAPI6108-type,
io_txsht like BAPI6108-textshort,
io_txlng like BAPI6108-textlong,
io_datatype like BAPI6108-datatp,
io_length like BAPI6108-intlen,
END OF itab-bapi.
DATA ibapi LIKE STANDARD TABLE OF itab-bapi.
PARAMETERS: sel_file(1500) TYPE c default ' ' OBLIGATORY LOWER CASE.
PUT THE TEXT FILE PATH TO P_FILE
p_file = sel_file.
Copy the file from the workstation to the server ****
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = p_file
<b>FILETYPE = 'ASC'
HAS_FIELD_SEPARATOR = 'X'</b>
TABLES
data_tab = itab-bapi[]
EXCEPTIONS
file_open_error = 1
file_read_error = 2
no_batch = 3
gui_refuse_filetransfer = 4
invalid_type = 5
no_authority = 6
unknown_error = 7
bad_data_format = 8
header_not_allowed = 9
separator_not_allowed = 10
header_too_long = 11
unknown_dp_error = 12
access_denied = 13
dp_out_of_memory = 14
disk_full = 15
dp_timeout = 16
not_supported_by_gui = 17
error_no_gui = 18
OTHERS = 19.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
MESSAGE e012(zea_spms) WITH 'Method' 'GUI_UPLOAD' sy-subrc.
&1 &2 issued return code &3
ELSE.
pit_data[] = lit_data[].
ENDIF.
ENDIF.
loop at itab-bapi.
write: /5 itab-bapi-io_name,
20 itab-bapi-io_type,
30 itab-bapi-io_txsht,
50 itab-bapi-io_txlng,
75 itab-bapi-io_datatype,
85 itab-bapi-io_length.
endloop.
SELECT THE LOCATION FOR TEXT FILE
AT SELECTION-SCREEN ON VALUE-REQUEST FOR sel_file.
CALL FUNCTION 'WS_FILENAME_GET'
EXPORTING
def_filename = ''
def_path = 'C:\'
mask = ',Documentos de texto (*.txt), *.txt.'
mode = ''
IMPORTING
filename = p_file
EXCEPTIONS
inv_winsys = 1
no_batch = 2
selection_cancel = 3
selection_error = 4
OTHERS = 5.
find '.txt' IN p_file.
if sy-subrc <> 0.
concatenate p_file '.txt' into sel_file.
else.
sel_file = p_file.
endif.
Create InfoObject through BAPI Function
*CALL FUNCTION 'BAPI_IOBJ_CREATE'.
*IMPORTING
VALUE(DETAILS) LIKE BAPI6108 STRUCTURE BAPI6108
*EXPORTING
VALUE(INFOOBJECT) LIKE BAPI6108-INFOOBJECT
VALUE(RETURN) LIKE BAPIRET2 STRUCTURE BAPIRET2
TABLES
COMPOUNDS STRUCTURE BAPI6108CM OPTIONAL
ATTRIBUTES STRUCTURE BAPI6108AT OPTIONAL
NAVIGATIONATTRIBUTES STRUCTURE BAPI6108AN OPTIONAL
ATRNAVINFOPROVIDER STRUCTURE BAPI6108NP OPTIONAL
HIERARCHYCHARACTERISTICS STRUCTURE BAPI6108HC OPTIONAL
ELIMINATION STRUCTURE BAPI6108IE OPTIONAL
RETURNTABLE STRUCTURE BAPIRET2 OPTIONAL
Activate InfoObject through BAPI Function
CALL FUNCTION 'BAPI_IOBJ_ACTIVATE_MULTIPLE'
*ENDFORM. " RETRIEVE_DATASET
This program is working fine. You can test it.
Only problem is as the column headings are big for some columns, they are getting truncated which you can always change by changing the column width in declaration
Please let me know if this helps.
ashish
Maybe you are looking for
-
Power Problem (Adapter doesn't light up)
On my Powerbook, which is about 1.5 years old, the adaptor charge light went off. The battery drained after this happened (Adaptor is no longer charging). The first time this happened I tried pulling out the battery for five min, and restarting. That
-
What add on do i need to remove to stop the following error
keyword Add-on![Exception... "Component returned failure code: 0x8000ffff (NS_ERROR_UNEXPECTED) [nsIPrefBranch.getCharPref]" nsresult: "0x8000ffff (NS_ERROR_UNEXPECTED)" location: "JS frame :: chrome://keywords/content/overlay.xul :: <TOP_LEVEL> :: l
-
Mobile Version: How to see all highlights and notes we made in a PDF document?
Mobile Version (Android): How to see all highlights and notes we made in a PDF document?
-
Hi, Last December I bought a download of Elements 8 and installed it on my PC, registered it etc. I have now bought a new PC and want to transfer Elements to the new machine, I do not have the original download files - any ideas how to do it? Thanks,
-
SMC4.0 keeps hanging at "unable to load console info"
i installed, reinstalled, reinstalled and so on SunMC 4.0 on a X4140 and did everything that was described in the manual. But still SunMC doesn't work. i have 2 problems now: 1. the webserver at 6789 doesnt work anymore 2. when i use the Java-applet