Some of the columns of a table are not displayed in popup display ABAP - popup

I'm assigning a button to display my table at SAP. I've achieved this with popup_with_table_display. In the popup screen I can see some of my columns but not all of them. Here's my code:
DATA: t_interview TYPE TABLE OF ZBS_HR_I0001
CASE sy-ucomm.
WHEN 'DISP'.
select * from ZBS_HR_I0001 into table t_interview.
CALL FUNCTION 'POPUP_WITH_TABLE_DISPLAY'
EXPORTING
ENDPOS_COL = 100
ENDPOS_ROW = 10
STARTPOS_COL = 10
STARTPOS_ROW = 1
TITLETEXT = 'Interview Table'
TABLES
VALUETAB = t_interview
EXCEPTIONS
BREAK_OFF = 1
OTHERS = 2
.
BTW this code section works inside my PAI.
Here's the output that I'm getting.
And here's the original table with all of its columns. How can I make it display all of my columns?

Here's the working code for me:
DATA: t_interview TYPE TABLE OF ZBS_HR_I0001,
ts_interview TYPE REF TO cl_salv_table.
select * from ZBS_HR_I0001 into table t_interview.
cl_salv_table=>factory(
IMPORTING
r_salv_table = ts_interview
CHANGING
t_table = t_interview
).
CASE sy-ucomm.
WHEN 'DISP'.
ts_interview->display( ).
ENDCASE.

Related

Column is not updating in postgresql

I tried to update my table like below:
$query = "select *
FROM sites s, companies c, tests t
WHERE t.test_siteid = s.site_id
AND c.company_id = s.site_companyid
AND t.test_typeid = '20' AND s.site_id = '1337'";
$queryrow = $db->query($query);
$results = $queryrow->as_array();
foreach($results as $key=>$val){
$update = "update tests set test_typeid = ? , test_testtype = ? where test_siteid = ?";
$queryrow = $db->query($update,array('10','Meter Calibration Semi Annual',$val->site_id));
}
The above code is working good. But in update query , The column test_typeid is not updated with '10'. Column test_typeid is updating with empty value. Other columns are updating good. I dont know why this column test_typeid is not updating? And the column test_typeid type is integer only. I am using postgreSql
And My table definition is:
What i did wrong with the code. Kindly advice me on this.
Thanks in advance.
First, learn to use proper JOIN syntax. Never use commas in the FROM clause; always use proper explicit JOIN syntax.
You can write the query in one statement:
update tests t
set test_typeid = '10',
test_testtype = 'Meter Calibration Semi Annual'
from sites s join
companies c
on c.company_id = s.site_companyid
where t.test_siteid = s.site_id and
t.test_typeid = 20 and s.site_id = 1337;
I assume the ids are numbers, so there is no need to use single quotes for the comparisons.

How to get table rows from sqlite_master using tbl_name

I am trying to get a table based on the rootpage number/tbl_name and store in a custom TableObject.
I am able to get the table name by the root page number/tbl_name, but I have no idea about getting the row values from that table.
Here is what I have:
SELECT * FROM sqlite_master WHERE name='test1';
or
SELECT * FROM sqlite_master WHERE rootpage=4;
This thing gives me a row which has a table .
Now how can I get the test1 contents ?
The test1 table have two rows in it, called age and name. How can I access those columns ?
At the end I end up using the cursor, so the query will be something like:
cursor=db.rawQuery("SELECT * FROM sqlite_master WHERE rootpage = '" + rootNumber + "'",null);
I can use
cursor.getString(getColumnIndex("name")) //w.r.t sqlite_master
cursor.getString(getColumnIndex("rootpage")) //w.r.t sqlite_master
How can I use the same cursor to get something like:
cursor.getString(getColumnIndex("age")) //w.r.t test1
cursor.getString(getColumnIndex("name")) //w.r.t test1
to get the values from the resulted table.
I would suggest you that once you query sqlite_master table using cursor A, don't use the same cursor A as it contains result of the that query result.
Hence you need to fire another query and store the next result in another cursor B so that you don't lose the data from your first query.
For example, for master table,you do something like :
Cursor cursorA = db.rawQuery("SELECT * FROM sqlite_master WHERE rootpage = '" + rootNumber + "'",null);
cursorA.moveToFirst();
String tableName = cursorA.getString(getColumnIndex("name"));
For further getting result from the table "test1" that you got result from the previous query, you can do something like this :
Cursor cursorB = db.rawQuery("SELECT * FROM '" + tableName + "'",null);
cursorB.moveToFirst();
String name= cursorB.getString(getColumnIndex("name")) ;
int age= cursorB.getString(getColumnIndex("age")) ;
Hence you will get the result that you need further from table "test1".
Hope this helps you :)

how can one table name used more than once in query of postgresql

I create view in the postgresql that for write query but error message display table name used more than once. How to solve this problem?
Query
SELECT
tbcitizen.firstname || '-' || tbcitizen.middlename || '-' || tbcitizen.familyname as firstname,
tbcitizen.dateofbirth,
tbcity.cityname,
tbcontact.contactdetails,
tbcitizen.citizenidp
FROM
public.tbcitizen,
public.tbaddress,
public.tbcity,
public.tbcontact
INNER JOIN
tbcontact ON tbcitizen.citizenidp = tbcontact.referenceidf AND tbcontact.referencetypeidf = 1 AND
tbcontact.isprimery = 1 INNER JOIN
tbaddress ON tbcitizen.citizenidf = tbaddress.referenceidf AND tbaddress.referencetypeidf = 1 AND
tbaddress.isprimery = 1 INNER JOIN
tbcity ON tbaddress.cityidf = tbcity.cityidp
WHERE
tbaddress.referencetypeidf = tbcitizen.citizenidp AND
tbaddress.referenceidf = tbcitizen.citizenidp AND
tbaddress.cityidf = tbcity.cityidp
Error = table name "tbcontact" specified more than once
Thanks
As the error states that - your table tbcontact used 2 times as the source table. So it creates ambiguity for the postgres database engine. So to resolve this issue you have to use table alias with different name.
Hope it'll help you.

Report Server - Can't declare parameters

My problem is that I was not able to declare parameters through Report Builder.
I was receiving the following error:
ERROR [42000] [Microsoft][ODBC SQL Server Driver][SQL Server]Must
declare the scalar variable "#param".
So I googled it and found that it can be solved easily by putting symbol "?" instead of "#parameter" and it did solved my problem for a while.
But now I have another problem. I have a select like:
select * from table t where t.date = ? or t.date2 = ? or t.date3 = ?
Where all three "?" are '2013-aug-01', but each "?" creates a new parameter in the parameters section of Report Builder.
How can I use one parameter for all three cases?
Try this
select * from table t where ? IN (t.date, t.date2, t.date3)
Another way of solving is just delete the two variables created by SSRS and update your query to
select * from table t where t.date = #param1 or t.date2 = #param1 or t.date3 = #param1
Another method write your query
select * from table t where t.date = ? or t.date2 = ? or t.date3 = ?
Let it create the 3 variables. Then go to Dataset, under dataset properties goto parameters section. There update the parameter value of 2 & 3 to Parameter1. Next go in the parameters section and delete the automatically generated Parameter2 & Parameter3.

Metadata about a column in SQL Server 2008 R2?

I'm trying to figure out a way to store metadata about a column without repeating myself.
I'm currently working on a generic dimension loading SSIS package that will handle all my dimensions. It currently does :
Create a temporary table identical to the given table name in parameters (this is a generic stored procedure that receive the table name as parameter, and then do : select top 0 * into ##[INSERT ORIGINAL TABLE NAME HERE] from [INSERT ORIGINAL TABLE NAME HERE]).
==> Here we insert custom code for this particular dimension that will first query the data from a datasource and get my delta, then transform the data and finally loads it into my temporary table.
Merge the temporary table into my original table with a T-SQL MERGE, taking care of type1 and type2 fields accordingly.
My problem right now is that I have to maintain a table with all the fields in it to store a metadata to tell my scripts if this particular field is type1 or type2... this is nonsense, I can get the same data (minus type1/type2) from sys.columns/sys.types.
I was ultimately thinking about renaming my fields to include their type in it, such as :
FirstName_T2, LastName_T2, Sex_T1 (well, I know this can be type2, let's not fall into that debate here).
What do you guyz would do with that? My solution (using a table with that metadata) is currently in place and working, but it's obvious that repeating myself from the systables to a custom table is nonsense, just for a simple type1/type2 info.
UPDATE: I also thought about creating user defined types like varchar => t1_varchar, t2_varchar, etc. This sounds like something a bit sluggy too...
Everything you need should already be in INFORMATION_SCHEMA.COLUMNS
I can't follow your thinking of not using provided tables/views...
Edit: As scarpacci mentioned, this somewhat portable if needed.
I know this is bad, but I will post an answer to my own question... Thanks to GBN for the help tho!
I am now storing "flags" in the "description" field of my columns. I, for example, can store a flag this way : "TYPE_2_DATA".
Then, I use this query to get the flag back for each and every column :
select columns.name as [column_name]
,types.name as [type_name]
,extended_properties.value as [column_flags]
from sys.columns
inner join sys.types
on columns.system_type_id = types.system_type_id
left join sys.extended_properties
on extended_properties.major_id = columns.object_id
and extended_properties.minor_id = columns.column_id
and extended_properties.name = 'MS_Description'
where object_id = ( select id from sys.sysobjects where name = 'DimDivision' )
and is_identity = 0
order by column_id
Now I can store metadata about columns without having to create a separate table. I use what's already in place and I don't repeat myself. I'm not sure this is the best possible solution yet, but it works and is far better than duplicating information.
In the future, I will be able to use this field to store more metadata, where as : "TYPE_2_DATA|ANOTHER_FLAG|ETC|OH BOY!".
UPDATE :
I now store the information in separate extended properties. You can manage extended properties using sp_addextendedproperty and sp_updateextendedproperty stored procedures. I have created a simple store procedure that help me to update those values regardless if they currently exist or not :
create procedure [dbo].[UpdateSCDType]
#tablename nvarchar(50),
#fieldname nvarchar(50),
#scdtype char(1),
#dbschema nvarchar(25) = 'dbo'
as
begin
declare #already_exists int;
if ( #scdtype = '1' or #scdtype = '2' )
begin
select #already_exists = count(1)
from sys.columns
inner join sys.extended_properties
on extended_properties.major_id = columns.object_id
and extended_properties.minor_id = columns.column_id
and extended_properties.name = 'ScdType'
where object_id = (select sysobjects.id from sys.sysobjects where sysobjects.name = #tablename)
and columns.name = #fieldname
if ( #already_exists = 0 )
begin
exec sys.sp_addextendedproperty
#name = N'Scd_Type',
#value = #scdtype,
#level0type = N'SCHEMA',
#level0name = #dbschema,
#level1type = N'TABLE',
#level1name = #tablename,
#level2type = N'COLUMN',
#level2name = #fieldname
end
else
begin
exec sys.sp_updateextendedproperty
#name = N'Scd_Type',
#value = #scdtype,
#level0type = N'SCHEMA',
#level0name = #dbschema,
#level1type = N'TABLE',
#level1name = #tablename,
#level2type = N'COLUMN',
#level2name = #fieldname
end
end
end
Thanks again