11-07-2012 5:28 PM
Hi All,
I am new to ABAP and recently working on Production support Project..
Some developer guy wrote the code for an object as mentioned below with the if condition comparison
If Z_VAR = 'Sd'
Else.
Endif.
Since the comparison value in the quotes should be capital code, always the code went into the Else part and created some junk data in many tables.
Please tell me your suggestions to remove this junk data which is created in a Z Field. Also I have one more issue..
I wrote the code as follows. for identifying the number of entries in the effected table
Data : gv_tab Type TABNAME,
gv_count Type I,
TB_TABLES Type Standard Table Of DD02L,
X_TABLES Like Line of TB_TABLES.
Tables : DD02L.
Select-options : SO_TAB For DD02L-TABNAME.
Select TABNAME From DD02L into corresponding fields of TB_TABLES Where TABNAME in SO_TAB
Loop At TB_TABLES Into X_TABLES.
GV_TAB = X_TABLES-TABNAME.
Select count (*) from (GV_TAB) Into GV_COUNT.-------------------->>>> Dumping here
Endloop.
I am stuck here what could be the problem please help...
thanks,
Jaggi
11-08-2012 9:16 AM
Hi Hope the below code works well for you...
It is dumping at the Select Count* because when you try to do a count on Structure or a view system does behave like that. the below FM will avoid that..
TABLES : dd02l.
DATA : gv_tab TYPE tabname,
gv_count TYPE i,
tb_tables TYPE STANDARD TABLE OF dd02l,
x_tables LIKE LINE OF tb_tables,
lv_subrc TYPE syst-subrc.
FIELD-SYMBOLS : <table> TYPE ANY.
SELECT-OPTIONS : so_tab FOR dd02l-tabname.
SELECT * FROM dd02l
INTO TABLE tb_tables
WHERE tabname IN so_tab.
LOOP AT tb_tables INTO x_tables.
CLEAR: lv_subrc.
ASSIGN x_tables-tabname TO <table>.
CALL FUNCTION 'DD_EXISTS_DATA'
EXPORTING
tabclass = x_tables-tabclass
tabname = x_tables-tabname
IMPORTING
subrc = lv_subrc
EXCEPTIONS
missing_reftab = 1
sql_error = 2
buffer_overflow = 3
unknown_error = 4
OTHERS = 5.
IF lv_subrc EQ 0.
SELECT COUNT(*) FROM (<table>) INTO gv_count.
If Sy-Subrc = 0.
Write 😕 'Table:', <table>, 'Count:', gv_count.
endIf.
ENDIF.
ENDLOOP.
Coming to your first part... Do the following steps.
1. identify the Z field where it is being used.
2. check the programs or FMs that uses this field whether they update your table or this Zfield.
3. write a extraction program or a mapping program to correct the data.
4. One the Impact is identified Also check the following program to scan the KEYWORD or with your ZFIELD etc...
RPR_ABAP_SOURCE_SCAN
Hope this helps....
11-07-2012 5:48 PM
Hi Jagdish...
What should I do?
- In the first issue.. you could either create a constant to compare with and, if the value should always be in capitals, use a TRANSLATE TO UPPER CASE applied to the var which is going to be compared. Obviously, there's a smarter but laborious method that consists in creating a table in SE11 which will contain variables values... better use the first
- In the second, I would definitely use a Field-symbol to contain the value of the table; so your code would look like this:
Tables : DD02L.
Data : gv_tab Type TABNAME,
gv_count Type I,
TB_TABLES Type Standard Table Of DD02L,
X_TABLES like Line of TB_TABLES.
*----
field-symbols : <table> type tabname.
*----
Select-options : SO_TAB For DD02L-TABNAME.
Select TABNAME From DD02L into corresponding fields of table TB_TABLES Where TABNAME in SO_TAB.
Loop At TB_TABLES Into X_TABLES.
* GV_TAB = X_TABLES-TABNAME.
assign x_tables-tabname to <table>.
Select count(*) from (<table>) Into GV_COUNT.
Endloop.
Hope this helps.
Kind Regards.
Santiago.
11-07-2012 7:12 PM
Hi Jagdish,
For the First issue create a conversion program to update the Zfield value with correct value.
For the second issue.
I tried the below code and it's working fine for me.
Send me what dump your getting.
Copy and paste the below code and execute to see the results.
DATA : gv_tab TYPE tabname,
gv_count TYPE i,
tb_tables TYPE STANDARD TABLE OF dd02l,
x_tables LIKE LINE OF tb_tables.
TABLES : dd02l.
SELECT-OPTIONS : so_tab FOR dd02l-tabname.
SELECT tabname
FROM dd02l
INTO CORRESPONDING FIELDS OF TABLE tb_tables
WHERE tabname IN so_tab.
LOOP AT tb_tables INTO x_tables.
gv_tab = x_tables-tabname.
SELECT COUNT(*) FROM (gv_tab) INTO gv_count.
ENDLOOP.
WRITE : gv_count.
11-07-2012 9:32 PM
What's the content of GV_TAB when it short-dumps? Make sure it contains a valid table name.
11-08-2012 6:52 AM
Hi you all.
What I'll also do is to put a checking of the value the table name... obvioulsy, when you're in the loop it must have a correct value because it's been extracted from the table DD02L (unless it could have been deleted if it's a customer table).
For example, in my code, it could be useful to write:
Loop At TB_TABLES Into X_TABLES.
assign x_tables-tabname to <table>.
if <table> is assigned.
Select count(*) from (<table>) Into GV_COUNT.
else.
continue.
endif.
Endloop.
But, as many more asked before, the ST22 log would definitely helps...
Kind Regards.
Santiago.
11-08-2012 9:16 AM
Hi Hope the below code works well for you...
It is dumping at the Select Count* because when you try to do a count on Structure or a view system does behave like that. the below FM will avoid that..
TABLES : dd02l.
DATA : gv_tab TYPE tabname,
gv_count TYPE i,
tb_tables TYPE STANDARD TABLE OF dd02l,
x_tables LIKE LINE OF tb_tables,
lv_subrc TYPE syst-subrc.
FIELD-SYMBOLS : <table> TYPE ANY.
SELECT-OPTIONS : so_tab FOR dd02l-tabname.
SELECT * FROM dd02l
INTO TABLE tb_tables
WHERE tabname IN so_tab.
LOOP AT tb_tables INTO x_tables.
CLEAR: lv_subrc.
ASSIGN x_tables-tabname TO <table>.
CALL FUNCTION 'DD_EXISTS_DATA'
EXPORTING
tabclass = x_tables-tabclass
tabname = x_tables-tabname
IMPORTING
subrc = lv_subrc
EXCEPTIONS
missing_reftab = 1
sql_error = 2
buffer_overflow = 3
unknown_error = 4
OTHERS = 5.
IF lv_subrc EQ 0.
SELECT COUNT(*) FROM (<table>) INTO gv_count.
If Sy-Subrc = 0.
Write 😕 'Table:', <table>, 'Count:', gv_count.
endIf.
ENDIF.
ENDLOOP.
Coming to your first part... Do the following steps.
1. identify the Z field where it is being used.
2. check the programs or FMs that uses this field whether they update your table or this Zfield.
3. write a extraction program or a mapping program to correct the data.
4. One the Impact is identified Also check the following program to scan the KEYWORD or with your ZFIELD etc...
RPR_ABAP_SOURCE_SCAN
Hope this helps....
11-08-2012 1:08 PM
Adding one more point...
Check with SAP SALT application if you got installed...
Code Matrix...It helps in identifying the impact for you case by showing UPDATE or INSERT or any sql commits to DB with the Hardcode value etc...
11-08-2012 2:54 PM
Thanks Venkat.. Ur solution worked.. It is dumping because of I am getting a view name first...
Also u explained in detail for junk data issue.. SCAN Program is good.. thanks for ur help...
Also thanks to all...