Urgent help in modif table inside subroutine
hi,
i have written as subroutine inside it i am trying to delete from an table contents of some fields .this table is defined in my main program whic is has an structure defined inside it
afetr that i am passing the table to my subroutin n inside subrounti i am trying to manupulate the table contenets then i am getting the syntax erroer "table is not active or not defined in data dictonary" what wil be the cause for this..,..is there any way so thjat i can manupulate it.???
pls help
points reward for useful answers
ravi
hi you are using Data base table commands instead of internal table commands...
try these types:
DATA scarr_tab TYPE SORTED TABLE OF scarr
WITH UNIQUE KEY carrid.
DATA scarr_wa TYPE scarr.
SELECT *
FROM scarr
INTO TABLE scarr_tab.
READ TABLE scarr_tab INTO scarr_wa
WITH TABLE KEY carrid = p_carrid.
scarr_wa-currcode = 'EUR'.
MODIFY TABLE scarr_tab FROM scarr_wa
TRANSPORTING currcode.
SELECT *
FROM scarr
INTO TABLE scarr_tab.
READ TABLE scarr_tab
WITH TABLE KEY carrid = p_carrid
TRANSPORTING NO FIELDS.
idx = sy-tabix.
scarr_wa-currcode = 'EUR'.
MODIFY scarr_tab INDEX idx FROM scarr_wa
TRANSPORTING currcode.
Similar Messages
-
Need urgent help on nested tables
Everywhere i could find a single nested table but not two. Can anyone help me on how to access and assign multi nested tables ?
Declare
Type a is table of varchar2(1000);
Type b is table of a;
v_temp b;
Begin
How can i assign and access variable of v_temp ?
Please help as i can find one level nested tables examples but not this type ?
end;SQL> set serveroutput on
SQL> Declare
2 Type a is table of varchar2(1000);
3 Type b is table of a;
4 v_temp b := b();
5 Begin
6 v_temp.extend(2);
7 v_temp(1) := a('A','B','C');
8 v_temp(2) := a('1','2','3','4','5');
9 for i in 1..v_temp.count loop
10 for j in 1.. v_temp(i).count loop
11 dbms_output.put_line('v_temp('||i||')('||j||') = '||v_temp(i)(j));
12 end loop;
13 end loop;
14 End;
15 /
v_temp(1)(1) = A
v_temp(1)(2) = B
v_temp(1)(3) = C
v_temp(2)(1) = 1
v_temp(2)(2) = 2
v_temp(2)(3) = 3
v_temp(2)(4) = 4
v_temp(2)(5) = 5
PL/SQL procedure successfully completed.
SQL> SY. -
Urgent help in multiple table update query
TABLE1
NAME
RATE
TABLE2
NAME RATE1 DATE1
NAME RATE2 DATE2
NAME RATE3 DATE3
Can anyone help me to write a query which can update RATE in TABLE1 based on
following criteria ?
We have same column 'NAME' in both the tables.
First Find maximum Date from the TABLE2 and then take correspoinding rate from TABLE2 and update with the RATE column in TABLE1.Works as expected for me:
SQL> CREATE TABLE TABLE1 (
2 NAME VARCHAR2(10),
3 RATE NUMBER
4 );
Tabelle wurde erstellt.
SQL> CREATE TABLE TABLE2 (
2 NAME VARCHAR2(10),
3 RATE NUMBER,
4 DT DATE
5 );
Tabelle wurde erstellt.
SQL> INSERT INTO TABLE1 VALUES ('NAME1', NULL);
1 Zeile wurde erstellt.
SQL> INSERT INTO TABLE1 VALUES ('NAME2', NULL);
1 Zeile wurde erstellt.
SQL> INSERT INTO TABLE1 VALUES ('NAME3', NULL);
1 Zeile wurde erstellt.
SQL>
SQL> INSERT INTO TABLE2 VALUES ('NAME1', 1, SYSDATE);
1 Zeile wurde erstellt.
SQL> INSERT INTO TABLE2 VALUES ('NAME1', 2, SYSDATE-1);
1 Zeile wurde erstellt.
SQL> INSERT INTO TABLE2 VALUES ('NAME1', 3, SYSDATE-2);
1 Zeile wurde erstellt.
SQL>
SQL> INSERT INTO TABLE2 VALUES ('NAME2', 1, SYSDATE+1/1440);
1 Zeile wurde erstellt.
SQL> INSERT INTO TABLE2 VALUES ('NAME2', 2, SYSDATE+2/1440);
1 Zeile wurde erstellt.
SQL> INSERT INTO TABLE2 VALUES ('NAME2', 3, SYSDATE+3/1440);
1 Zeile wurde erstellt.
SQL> update table1 t1 set
2 rate = (select t2.rate
3 from table2 t2
4 where t2.dt = (select max(t3.dt)
5 from table2 t3
6 where t3.name=t2.name
7 )
8 and t2.name=t1.name
9 );
3 Zeilen wurden aktualisiert.
SQL> select name, rate from table1;
NAME RATE
NAME1 1
NAME2 3
NAME3
SQL> INSERT INTO TABLE2 VALUES ('NAME3', 1, TRUNC(SYSDATE));
1 Zeile wurde erstellt.
SQL> INSERT INTO TABLE2 VALUES ('NAME3', 2, TRUNC(SYSDATE));
1 Zeile wurde erstellt.
SQL> update table1 t1 set
2 rate = (select t2.rate
3 from table2 t2
4 where t2.dt = (select max(t3.dt)
5 from table2 t3
6 where t3.name=t2.name
7 )
8 and t2.name=t1.name
9 )
10 ;
rate = (select t2.rate
FEHLER in Zeile 2:
ORA-01427: Unterabfrage für eine Zeile liefert mehr als eine Zeile -
Urgent Help on Dynamic Table name change in query !!!!!!!!
Hi Everyone,
I'm having a repeating frame which displays table_name, count_validate and count_error. How can i dynamically change my table_name in formula column apllied on count_validate and count_error. I can do this with multiple elsif statement, which makes my report slow at runtime. Select statement is same , only change is table_name ?
Kindly let me know......Try to use dynamic ref cursors (defined in a database package).
This is not exactly what you need, but see:
"Dynamic Table in the Second Query with Oracle Reports"
http://www.quest-pipelines.com/pipelines/plsql/tips03.htm#JULY
Regards,
Zlatko Sirotic -
Urgent help needed!! Layout table and Draw layout cell dissapeared.
I need some urgent help. I'm using CS3 but for a while my
Layout Table and Draw Layout Cell icons appear greyed and can't use
them at all. Is there any kind soul out there who knows how to fix
this? I'm going nuts trying all the possible options but none seem
to work.
Help please!!!!!!> How would you about designing a page without using html?
You don't. But I don't recall suggesting that you not use
HTML. I just
suggested that you use best-practice HTML, no? Or maybe you
meant to ask
how you would go about building your site without learning
HTML? In that
case, I think you are outta luck. Using DW without knowing
HTML is a very
punishing experience, I'm afraid.
> PS: A virtual box of 12 bottles of Moet Chandon is
already on your way!!
I'd prefer Cristal, please.
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.projectseven.com/go
- DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs,
Tutorials & Resources
==================
"Untersberg" <[email protected]> wrote in
message
news:g4tj9a$m5o$[email protected]..
> Ahhhhhh!!!!! They came up!!!! They came up again!!
> I was on standard mode. Now going back to your
suggestion, which I really
> appreciate. How would you about designing a page without
using html? I'm
> just
> redesigning my website at the moment and need it to get
going urgently,
> hence
> the reluctance to start learning HTML at the moment.
I'll do after but I
> need
> to get this up and running fairly quickly.
>
> Cheers.
>
> PS: A virtual box of 12 bottles of Moet Chandon is
already on your way!!
> -
Fetch the values from internal table inside an internal table (urgent!!)
data : BEGIN OF PITB2_ZLINFO occurs 0,
BEGDA LIKE SY-DATUM,
ENDDA LIKE SY-DATUM,
PABRJ(4) TYPE N, "Payroll Year
PABRP(2) TYPE N, "Pay. Period
ZL LIKE PC2BF OCCURS 0,
END OF PITB2_ZLINFO.
I have a internal table like this,
How to Fetch the values from internal table inside an internal table.
Kindly Help me on this..
Regards,
Ram.Hi,
Try this....
Loop at PITB2_ZLINF0.
Loop at PITB2_ZLINF0-ZL.
endloop.
Endloop.
Thanks...
Preetham S -
Urgent help in coding of creating New Business partner?
Hi Friends,
I need urgent help on this.Please give me the solution.
This is the coding which i written for creating new BP.
FUNCTION ZCTS_NEW_CONTACT.
""Local interface:
*" IMPORTING
*" VALUE(BUSINESSPARTNER) LIKE BAPIBUS1006_HEAD-BPARTNER
*" VALUE(CNEWINFO) TYPE ZCTS_CONTACTS
*" VALUE(CDATA) LIKE BAPIBUS1006_CENTRAL STRUCTURE
*" BAPIBUS1006_CENTRAL
*" VALUE(BUSPART1) LIKE BAPIBUS1006_RELHEAD-BUSINESSPARTNER1
*" VALUE(BUSPART2) LIKE BAPIBUS1006_RELHEAD-BUSINESSPARTNER2
*" VALUE(RELCAT) LIKE BAPIBUS1006_RELHEAD-RELATIONSHIPCATEGORY
*" EXPORTING
*" VALUE(MESG) TYPE CHAR100
DATA: lt_return like bapiret2 occurs 0 with Header line.
DATA: CTPERS LIKE BAPIBUS1006_CENTRAL_PERSON OCCURS 0 WITH HEADER LINE.
DATA : PARTN_GRP TYPE BAPIBUS1006_HEAD-PARTN_GRP.
DATA : PARTN_CAT TYPE BAPIBUS1006_HEAD-PARTN_CAT.
DATA: BEGIN OF ADADD.
INCLUDE STRUCTURE BAPIBUS1006_ADDRESS.
DATA: END OF ADADD.
DATA: BEGIN OF ADTEL OCCURS 0.
INCLUDE STRUCTURE BAPIADTEL.
DATA: END OF ADTEL.
DATA: BEGIN OF ADSMP OCCURS 0.
INCLUDE STRUCTURE BAPIADSMTP.
DATA: END OF ADSMP.
CTPERS-FIRSTNAME = CNEWINFO-FNAME.
CTPERS-LASTNAME = CNEWINFO-LNAME.
PARTN_CAT = 1.
PARTN_GRP = 002.
ADADD-CITY = CNEWINFO-CITY .
telephone info **
ADTEL-TELEPHONE = CNEWINFO-PHONE.
ADTEL-CONSNUMBER = '001'.
APPEND ADTEL.
ADTEL-TELEPHONE = CNEWINFO-MOBILE.
ADTEL-CONSNUMBER = '002'.
APPEND ADTEL.
email information **
ADSMP-E_MAIL = CNEWINFO-EMAIL .
APPEND ADSMP.
CALL FUNCTION 'BAPI_BUPA_CREATE_FROM_DATA'
EXPORTING
PARTNERCATEGORY = PARTN_CAT
CENTRALDATA = CDATA
PARTNERGROUP = PARTN_GRP
CENTRALDATAPERSON = CTPERS
ADDRESSDATA = ADADD
IMPORTING
BUSINESSPARTNER = BUsinessPartner
TABLES
TELEFONDATA = ADTEL
E_MAILDATA = ADSMP
RETURN = lt_return.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = 'X'.
*PARTN_CAT = 1.
*PARTN_GRP = 002.
*ADADD-CITY = CNEWINFO-CITY .
telephone info **
ADTEL-TELEPHONE = CNEWINFO-PHONE.
ADTEL-CONSNUMBER = '001'.
APPEND ADTEL.
ADTEL-TELEPHONE = CNEWINFO-MOBILE.
ADTEL-CONSNUMBER = '002'.
APPEND ADTEL.
email information **
ADSMP-E_MAIL = CNEWINFO-EMAIL .
APPEND ADSMP.
CALL FUNCTION 'BAPI_BUPR_PFCT_CREATEFROMDATA'
EXPORTING
BUSINESSPARTNER1 = BUSPART1
BUSINESSPARTNER2 = BUSPART2
RELATIONSHIPCATEGORY = RELCAT
TABLES
RETURN = lt_return.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = 'X'.
LOOP AT lt_return WHERE TYPE = 'E'.
MESG = ' NOT CREATED NEW CONTACT'(020).
EXIT.
ENDLOOP.
ENDFUNCTION.
Early reply is highly appriciable.
Regards,
BONAHi,
Thanks for early reply.
When i tested created new BP.
Wheni check wether it is created or not its not created.
What is the problem.is there modifications i have to do int he coding.
Thanks,
BONA. -
How to convert PO sapscript layout to pdf - need VERY URGENT Help
Dear All,
Requirement: PO sapscript layout after some modifications (say, ZMEDRUCK) has to be converted to pdf. Through me9f user will be able to give ranges of PO numbers and can view the print preview for the po. After that on clicking the print button we get the printout of the pos one after another based on the user input of PO numbers.
Our requirement is that when the user will click on the "Print Preview" of po (rather than pressing the print button) it i.e. PO sapscript layout has to get converted to pdf.
If you have already encountered this scenario, could you please send me the source code regarding this at the earliest. If you want to email it to my personal id, please let me know so that I can give it to you. Thank you.
It will be very beneficial for mine if you can send me some source code in this regard. (FYI. We want only Print output of PO sapscript. So, Print Program /SMB40/FM06P [after copying it to our ZSMB40/FM06P program] need to be modified for downloading the PO into PDF where there is no FMs like OPEN_FORM, WRITE_FORM, CLOSE_FORM. So already available source code in SAP forums can not help me.)). Kindly help me at the earliest. Its VERY URGENT
Thank you.
Thanks & Regards
SudiptaHi Chaith,
Could you please provide me the source code regarding this at the earliest.
We want only Print output of PO sapscript. So we need to modify only the Print Program SAPFM06P after copying it to ZSAPFM06P for downloading of modified PO (ZMEDRUCK) sapscript layout into PDF.
I am already having some source code from sdn portral. I am attaching it herewith. But it's not working as some constants and variable values need to be given. We want to take download of PO into PDF from ME9F transaction itself.
Could you please provide necessary values in the missing constants and variables and kindly resend the corrected modified Source code to me so that I can run the same code to download the modified PO ZMEDRUCK into PDF . Need YOUR URGENT HELP...
DATA: l_druvo LIKE t166k-druvo,
l_nast LIKE nast,
aux_nast LIKE nast,
l_from_memory,
l_doc TYPE meein_purchase_doc_print,
ent_screen TYPE c,
ent_retco TYPE i,
toa_dara TYPE toa_dara,
arc_params LIKE arc_params,
aux_form LIKE tnapr-fonam.
DATA: otf LIKE itcoo OCCURS 0 WITH HEADER LINE,
lt_docs TYPE TABLE OF docs,
pdf_bytecount TYPE i,
nom_archivo TYPE string.
aux_form = 'ZMEDRUCK'.
l_from_memory = c_true.
SELECT *
FROM nast
INTO aux_nast
UP TO 1 ROWS
WHERE kappl = c_po " Purchase Order
AND objky = t_datos-ebeln
AND aktiv = space
ORDER BY erdat DESCENDING eruhr DESCENDING.
ENDSELECT.
aux_nast-sort1 = c_swp.
CLEAR ent_screen.
CLEAR ent_retco.
IF aux_nast-aende EQ space.
l_druvo = c_1.
ELSE.
l_druvo = c_2.
ENDIF.
l_druvo = '2'.
CALL FUNCTION 'ME_READ_PO_FOR_PRINTING'
EXPORTING
ix_nast = aux_nast
ix_screen = ent_screen
IMPORTING
ex_retco = ent_retco
ex_nast = l_nast
doc = l_doc
CHANGING
cx_druvo = l_druvo
cx_from_memory = l_from_memory.
CHECK ent_retco EQ 0.
CALL FUNCTION 'ECP_PRINT_PO'
EXPORTING
ix_nast = l_nast
ix_druvo = l_druvo
doc = l_doc
ix_screen = ent_screen
ix_from_memory = l_from_memory
ix_toa_dara = toa_dara
ix_arc_params = arc_params
ix_fonam = aux_form
IMPORTING
ex_retco = ent_retco.
CLEAR otf.
CALL FUNCTION 'READ_OTF_FROM_MEMORY'
EXPORTING
memory_key = l_nast-objky " PO Number
TABLES
otf = otf
EXCEPTIONS
memory_empty = 1
OTHERS = 2.
CALL FUNCTION 'CONVERT_OTF_2_PDF'
IMPORTING
bin_filesize = pdf_bytecount
TABLES
otf = otf
doctab_archive = lt_docs
lines = pdfout
EXCEPTIONS
err_conv_not_possible = 1
err_otf_mc_noendmarker = 2
OTHERS = 3.
CONCATENATE c_dest t_datos-ebeln c_ext INTO nom_archivo.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
bin_filesize = pdf_bytecount
filename = nom_archivo
filetype = c_bin
IMPORTING
filelength = pdf_bytecount
TABLES
data_tab = pdfout. -
Reporting Services - How to open a second table inside report, for each number of client (each apears in first table)?
Exemple:
Table1
Cliente name:
John
Client number:
12345
Survay number of negative answers:
3
Table2
Questions and answers that were negative:
Question: How much time where you waiting
Avaluation: 3 (from 1 to 10)
Answer: They only called me 1 mouth later
Can you please help me?Hi,
Based on the description, I understand that you want to add subreport in the main report. When previewing the main report, the subreport can be shown in detail. Please see the screenshots on my test:
In Reporting Services, we can create parameters and pass them from main report to subreport in order to control the data dynamically.
References:
Subreports (Report Builder and SSRS)
Add a Subreport and Parameters (Report Builder and SSRS)
If I have any misunderstanding, please feel free to contact me.
Regards,
Heidi Duan
Heidi Duan
TechNet Community Support -
Hi Gurus,
Please i need an urgent help from you guys. There is a demand file which consits of (Siteno(plant), Item No ,Item Description, Delivery due date) will be placed in a unix system or windows system. I need to write an interface which shows a radiobutton for unix & windows and fileupload button & download button.When user clicks should be able to select only one radiobutton (unix or windows) to upload or download.When the user clicks the fileupload / download button,it should pick up the file or drop the file at particular unix or windows system.
Please help me or give me sample code where in i can select the radiobutton and i can upload / download from unix or windows path. and during upload process (for both unix/windows) ,i should be able to persist into a custom table (ztable,if iam not wrong) and while downloading read the records from custome table and create an excel file to be placedon unix/windows based on the radio button.
Thanks in advance, i need ur help please.
Regards
BrunoHi Bruno,
Please checkout this code sample
ABAP code for uploading a TAB delimited file into an internal table.
The code is base on uploading a simple txt file.
<b>
http://www.sapdevelopment.co.uk/file/file_uptabpc.htm</b>
Thanks,
Aby -
Urgent help needed... PL/SQL Insert statement
Hi...
I need some urgent help on this project. I have a 2 column table with values that need to be inserted into another existing table which has a sequence.
This is the 2 column table:
FUND YEAR
29587 05
29587 07
Existing table:
Name Null? Type
LIST_ID NOT NULL NUMBER(6) -- This is a sequence
WEB_USER_ID NOT NULL VARCHAR2(10)
RESOURCE_TYPE NOT NULL VARCHAR2(8)
LIST_TYPE NOT NULL VARCHAR2(10)
LIST_NAME NOT NULL VARCHAR2(50)
LIST_CODE_1 NOT NULL VARCHAR2(6) -- FUND from table above
LIST_CODE_2 NOT NULL VARCHAR2(6) -- YEAR from table above
LIST_CODE_3 NOT NULL VARCHAR2(6)
LAST_UPDATED_DT NOT NULL DATE
LAST_UPDATED_BY NOT NULL VARCHAR2(10)
LIST_CODE_4 NOT NULL VARCHAR2(20)
The columns from table 1 (FUND, YEAR) correspond to columns (LIST_CODE_1, LIST_CODE_2) in table 2. The column LIST_ID is a sequence. I can put in sysdate for LAST_UPDATED_DT and my initials SN for LAST_UPDATED_BY. This is going to be for 2 unique WEB_USER_IDs which would be in the WHERE clause. I will be inserting 2200 rows for each id. A single insert statement would look like this -
INSERT INTO EXISTING_TBL (list_id,web_user_id,resource_type,list_type,list_name,list_code_1,list_code_2,list_code_3,list_code_4,last_updated_dt,last_updated_by) VALUES ('470027','WEBUSER','GL','FUNDFYF',' FUND BALANCE SUM','12010','01',' ',' ',{ts '2010-5-19 10:16:9'},'SN')
How would I do this to insert the 2200 values from my 2 column table to the existing table?
All help is greatly appreciated!!
SNHello ,
I think this will work
INSERT INTO TABLE2
LIST_ID,
WEB_USER_ID,
RESOURCE_TYPE,
LIST_TYPE,
LIST_NAME,
LIST_CODE_1,
LIST_CODE_2,
LIST_CODE_3,
LIST_CODE_4,
LAST_UPDATED_DT,
LAST_UPDATED_BY
SELECT
SEQ.NEXTVAL,
FUND,
YEAR,
<VALUE FOR RESOURCE_TYPE>,
<VALUE FOR LIST_TYPE>,
<VALUE FOR LIST_NAME>,
<VALUE FOR LIST_CODE_1>,
<VALUE FOR LIST_CODE_2>,
<VALUE FOR LIST_CODE_3>,
<VALUE FOR LIST_CODE_4>,
SYSDATE,
'SN'
FROM
TABLE1
REGARDS
Rahul Sharma -
Urgent help required in migration
Hello,
I am stuck on 77% of r3load process my all 15/16 processes are finished successfully only one process has failed I have cut paste the log (SAPAPPL1.log) below of the same. Request your urgent help.
DbSl Trace: Connecting via TNS_ADMIN=/oracle/F01/920_64/network/admin, tnsname=F01
DbSl Trace: Got NLS_LANG=AMERICAN_AMERICA.US7ASCII from environment
DbSl Trace: Now I'm connected to ORACLE
DbSl Trace: Database instance F01 is running on e027pae0 with ORACLE version 9.2.0.7.0
trying to restart import ###
(RIM) INFO: table "BKPF" truncated
restart finished ###
#START: 20070530101004
TAB: BKPF
(RD) ERROR: missing last block number for table "BKPF" in directory file "/sapcd/EXPDIR/DATA/SAPAPPL1.TOC"
#STOP: 20070530101004
Thanks & Regards,
BhushanDid you split the files?
It seems that export file for this table got corrupt.
Unfortunately, you ahve to start again. I had a similar problem and had to do it again. -
Urgent HELP required on forming the Matrix of data using PL/SQL
Hi All,
I'm new to this thread and require your urgent help in this regard.
I've got a requirement for building a 5000 X 5000 matrix using PL/SQL. My original data tables have 5000 rows each and I need to do a correlation analysis using this data and need to store in a physical table and not in-memory. Is this feat achievable using mere PL/SQL? I understand that Oracle DB has a limitation of 1000 columns(but not sure) and hence I'd like to know whether there is any work-around for such scenarios. If not, what are the other alternative method(s) to achieve this feat? Do I need to use any 3rd party tools to get this done? An early reply from the experts is highly appreciated.
Thanking you all Gurus in advance.
Rgds
SaiWelcome to OTN!
I'll get to your quesiton in a moment, but first some welcome information. Many OTN posters consider it impolite to mark threads as "urgent". We are volunteers and have jobs of our own to do without people we don't know making demands. You are brand new and deserve some patience but please understand this. It is very likely before I finish this post someone will complain about the word "urgent" in your subject.
On to more interesting things :)
You can do the matrix, but are out of luck with a 5000 x 5000 table because Oracle only allows 1000 columns per table. There are ways to work around this.
How do do the matrix depends on what you want to do. You can do this different ways. You can create a table beforehand and use PL/SQL or simple SQL to populate it, or use the CREATE TABLE AS syntax to create and populate it in one step if you can get the underlying SQL to work the way you want, something like
create table my_table as
select a.*, b.*
from table1 a, table2 bcan populate a matrix from 2 tables with an intentional cartesian join (the WHERE clause was left out intentionally, provided your data is already in the data base.
If not you can use a PL/SQL routine to populate the data.
There are a couple of ways to solve the 1000 column limit. The easiest way might be to have 5 collections of 1000 columns each. A more complicated but more elegant soltion would be to have nested collections, allowing 2 colliections that you can loop through - a collection of collections. Nested collections can be hard to work with. A third way would be to use nested tables in the database but I personally do not like them and the insert, update, and delete statements for nested tables are hard to use.
I'm not going to give a code example because I am not sure which solution is best for you. If you have further questions post them. -
Urgent Help Required for Connect Four Game
Hi all,
I am a student and I have a project due 20th of this month, I mean May 20, 2007 after 8 days. The project is about creating a Connect Four Game. I have found some code examples on the internet which helped me little bit. But there are lot of problems I am facing developing the whole game. I have drawn the Board and the two players can play. The players numbers can fill the board, but I have problem implementing the winner for the game. I need to implement the hasWon() method for Horizontal win, Vertical win and Diagonal win. I also found some code examples on the net but I was unable to make it working. I have 5 classes and one interface which I m implementing. The main problem is how to implement the hasWon() method in the PlayGame class below with Horizontal, vertical and diagonal moves.
Sorry there is so much code.
This the interface I must implement, but now I am only implementing the int move() of this interface. I will implement the rest later after solving the winner problem with your help.
Interface code..............
interface Player {
void init (Boolean color);
String name ();
int move ();
void inform (int i);
Player1 class......................
import java.util.*;
import java.io.*;
import javax.swing.*;
public class Player1 implements Player
public Player1()
public int move()
Scanner scan = new Scanner(System.in);
// BufferedReader stdin = new BufferedReader (new InputStreamReader(System.in));
int player1;
System.out.println ("What is your Number, player 1?");
player1 = scan.nextInt();
System.out.println ("Hey number"+player1+" are you prepared to CONNECT FOUR");
System.out.println();
return player1;
//Player.move();
//return player1;
}//end move method
public void init (Boolean color)
public void inform (int i)
public String name()
return "Koonda";
}//end player1 class
Player2 class...........................
import java.util.*;
import java.io.*;
import javax.swing.*;
public class Player2 implements Player
public int move()
//int cup0,cup1,cup2,cup3,cup4,cup5,cup6;
// cup0=5;cup1=5;cup2=5;cup3=5;cup4=5;cup5=5;cup6=5;
//int num1, num2;
Scanner scan = new Scanner(System.in);
// BufferedReader stdin = new BufferedReader (new InputStreamReader(System.in));
int player2;
System.out.println ("What is your Number, player 2?");
player2 = scan.nextInt();
System.out.println ("Hey "+player2+" are you prepared to CONNECT FOUR");
System.out.println();
//return player1;
return player2;
}//end move method
public void init (Boolean color)
public void inform (int i)
public String name()
return "malook";
}//end player1 class
PlayGame class which contains all the functionality.........................................................
import java.util.*;
import java.io.*;
import javax.swing.*;
public class PlayGame
//Player player1;
//Player player2;
int [][]ConnectFourArray;
boolean status;
int winner;
int player1;
int player2;
public PlayGame()
//this.player1 = player1;
//this.player2 = player2;
public void StartGame()
try{
// int X = 0, Y = 0;
//int value;
int cup0,cup1,cup2,cup3,cup4,cup5,cup6;
cup0=5;cup1=5;cup2=5;cup3=5;cup4=5;cup5=5;cup6=5;
int[][] ConnectFourArray = new int[6][7];
int num1, num2;
for(int limit=21;limit!=0;limit--)
BufferedReader selecter = new BufferedReader (new InputStreamReader(System.in));
String column1;
System.out.println();
for ( int row=0; row < ConnectFourArray.length; row++ ){
System.out.print("Row " + row + ": ");
for ( int col=0; col < ConnectFourArray[row].length; col++ )
System.out.print( ConnectFourArray[row][col] + " ");
System.out.println();
System.out.println();
System.out.println ("Please Select a column of 0 through 6 ");
column1 = selecter.readLine();
num1= Integer.parseInt(column1);
System.out.println();
if (num1==0){
ConnectFourArray[cup0][0]=1;
cup0=cup0-1;
else if (num1==1){
ConnectFourArray[cup1][1]=1;
cup1=cup1-1;
else if (num1==2){
ConnectFourArray[cup2][2]=1;
cup2=cup2-1;
else if (num1==3){
ConnectFourArray[cup3][3]=1;
cup3=cup3-1;
else if (num1==4){
ConnectFourArray[cup4][4]=1;
cup4=cup4-1;
else if (num1==5){
ConnectFourArray[cup5][5]=1;
cup5=cup5-1;
else if (num1==6){
ConnectFourArray[cup6][6]=1;
cup6=cup6-1;
System.out.println();
BufferedReader selecter2 = new BufferedReader (new InputStreamReader(System.in));
String column2;
System.out.println();
for ( int row=0; row < ConnectFourArray.length; row++ ){
System.out.print("Row " + row + ": ");
for ( int col=0; col < ConnectFourArray[row].length; col++ )
System.out.print( ConnectFourArray[row][col] + " ");
System.out.println();
System.out.println();
System.out.println ("Please Select a column of 0 through 6 ");
column1 = selecter.readLine();
num1= Integer.parseInt(column1);
System.out.println();
if (num1==0){
ConnectFourArray[cup0][0]=2;
cup0=cup0-1;
else if (num1==1){
ConnectFourArray[cup1][1]=2;
cup1=cup1-1;
else if (num1==2){
ConnectFourArray[cup2][2]=2;
cup2=cup2-1;
else if (num1==3){
ConnectFourArray[cup3][3]=2;
cup3=cup3-1;
else if (num1==4){
ConnectFourArray[cup4][4]=2;
cup4=cup4-1;
else if (num1==5){
ConnectFourArray[cup5][5]=2;
cup5=cup5-1;
else if (num1==6){
ConnectFourArray[cup6][6]=2;
cup6=cup6-1;
System.out.println();
System.out.println();
catch (Exception E){
System.out.println("Error with input");
System.out.println("Would you like to play again");
try{
String value;
BufferedReader reader = new BufferedReader (new InputStreamReader(System.in));
// Scanner scan = new Scanner(System.in);
System.out.println("Enter yes to play or no to quit");
// value = scan.nextLine();
// String value2;
value = reader.readLine();
//value2 = reader.readLine();
if (value.equals("yes"))
System.out.println("Start again");
StartGame(); // calling the StartGame method to play a game once more
else if (value.equals("no"))
System.out.println("No more games to play");
// System.exit(0);
else
System.exit(0);
System.out.println();
catch (Exception e){
System.out.println("Error with input");
finally
System.out.println(" playing done");
//StartGame();
//check for horizontal win
public int hasWon()
int status = 0;
for (int row=0; row<6; row++)
for (int col=0; col<4; col++)
if (ConnectFourArray[col][row] != 0 &&
ConnectFourArray[col][row] == ConnectFourArray[col+1][row] &&
ConnectFourArray[col][row] == ConnectFourArray[col+2][row] &&
ConnectFourArray[col][row] == ConnectFourArray[col+3][row])
//status = true;//int winner;
if(status == player1)
System.out.println("Player 1 is the winner");
else if(status == player2)
System.out.println("Player 2 is the winner" );
}//end inner for loop
}// end outer for loop
} // end method Winner
return status;
}//end class
ClassConnectFour which designs the board........................
import java.util.*;
import java.io.*;
import javax.swing.*;
public class ClassConnectFour
//Player player1;
//Player player2;
public ClassConnectFour()
//this.player1 = player1;
public void DrawBoard()
int[][] ConnectFourArray = new int[6][7] ;
for ( int row=0; row < ConnectFourArray.length; row++ ){
System.out.print("Row " + row + ": ");
for ( int col=0; col < ConnectFourArray[row].length; col++ )
System.out.print( ConnectFourArray[row][col] + " ");
System.out.println();
System.out.println();
}//end class
TestConnetFour class which uses most of the above class..................
import java.util.*;
import java.io.*;
import javax.swing.*;
public class TestConnectFour
public static void main(String[] args)
ClassConnectFour cf = new ClassConnectFour();
cf.DrawBoard();
Player1 player1 = new Player1();
Player2 player2 = new Player2();
player1.move();
player2.move();
System.out.println("Number 1 belongs to player " + player1.name());
System.out.println("Number 2 belongs to player " + player2.name());
PlayGame pg = new PlayGame();
pg.StartGame();
pg.hasWon();
//pg.Play();
//System.out.println(player.name());
//System.out.println(player2.name());
}// end main
}//end class
I am sorry for all this junk code but I only understand it this way. Your urgent help is required. Looking forward to your reply.
Thanks in advance.
Koonda
//Hi,
Thanks for your help but I really don't understand the table lookup algorithm. Could you please send me some code to implement that.
I will send you the formatted code as well
Thanks for your help.
looking forward to your reply.
Koonda
Hi all,
I am a student and I have a project due 20th of this month, I mean May 20, 2007 after 8 days. The project is about creating a Connect Four Game. I have found some code examples on the internet which helped me little bit. But there are lot of problems I am facing developing the whole game. I have drawn the Board and the two players can play. The players numbers can fill the board, but I have problem implementing the winner for the game. I need to implement the hasWon() method for Horizontal win, Vertical win and Diagonal win. I also found some code examples on the net but I was unable to make it working. I have 5 classes and one interface which I m implementing. The main problem is how to implement the hasWon() method in the PlayGame class below with Horizontal, vertical and diagonal moves.
Sorry there is so much code.
This the interface I must implement, but now I am only implementing the int move() of this interface. I will implement the rest later after solving the winner problem with your help.
Interface code..............
interface Player {
void init (Boolean color);
String name ();
int move ();
void inform (int i);
Player1 class......................
import java.util.*;
import java.io.*;
import javax.swing.*;
public class Player1 implements Player
public Player1()
public int move()
Scanner scan = new Scanner(System.in);
// BufferedReader stdin = new BufferedReader (new InputStreamReader(System.in));
int player1;
System.out.println ("What is your Number, player 1?");
player1 = scan.nextInt();
System.out.println ("Hey number"+player1+" are you prepared to CONNECT FOUR");
System.out.println();
return player1;
//Player.move();
//return player1;
}//end move method
public void init (Boolean color)
public void inform (int i)
public String name()
return "Koonda";
}//end player1 class
Player2 class...........................
import java.util.*;
import java.io.*;
import javax.swing.*;
public class Player2 implements Player
public int move()
//int cup0,cup1,cup2,cup3,cup4,cup5,cup6;
// cup0=5;cup1=5;cup2=5;cup3=5;cup4=5;cup5=5;cup6=5;
//int num1, num2;
Scanner scan = new Scanner(System.in);
// BufferedReader stdin = new BufferedReader (new InputStreamReader(System.in));
int player2;
System.out.println ("What is your Number, player 2?");
player2 = scan.nextInt();
System.out.println ("Hey "+player2+" are you prepared to CONNECT FOUR");
System.out.println();
//return player1;
return player2;
}//end move method
public void init (Boolean color)
public void inform (int i)
public String name()
return "malook";
}//end player1 class
PlayGame class which contains all the functionality.........................................................
import java.util.*;
import java.io.*;
import javax.swing.*;
public class PlayGame
//Player player1;
//Player player2;
int [][]ConnectFourArray;
boolean status;
int winner;
int player1;
int player2;
public PlayGame()
//this.player1 = player1;
//this.player2 = player2;
public void StartGame()
try{
// int X = 0, Y = 0;
//int value;
int cup0,cup1,cup2,cup3,cup4,cup5,cup6;
cup0=5;cup1=5;cup2=5;cup3=5;cup4=5;cup5=5;cup6=5;
int[][] ConnectFourArray = new int[6][7];
int num1, num2;
for(int limit=21;limit!=0;limit--)
BufferedReader selecter = new BufferedReader (new InputStreamReader(System.in));
String column1;
System.out.println();
for ( int row=0; row < ConnectFourArray.length; row++ ){
System.out.print("Row " + row + ": ");
for ( int col=0; col < ConnectFourArray[row].length; col++ )
System.out.print( ConnectFourArray[row][col] + " ");
System.out.println();
System.out.println();
System.out.println ("Please Select a column of 0 through 6 ");
column1 = selecter.readLine();
num1= Integer.parseInt(column1);
System.out.println();
if (num1==0){
ConnectFourArray[cup0][0]=1;
cup0=cup0-1;
else if (num1==1){
ConnectFourArray[cup1][1]=1;
cup1=cup1-1;
else if (num1==2){
ConnectFourArray[cup2][2]=1;
cup2=cup2-1;
else if (num1==3){
ConnectFourArray[cup3][3]=1;
cup3=cup3-1;
else if (num1==4){
ConnectFourArray[cup4][4]=1;
cup4=cup4-1;
else if (num1==5){
ConnectFourArray[cup5][5]=1;
cup5=cup5-1;
else if (num1==6){
ConnectFourArray[cup6][6]=1;
cup6=cup6-1;
System.out.println();
BufferedReader selecter2 = new BufferedReader (new InputStreamReader(System.in));
String column2;
System.out.println();
for ( int row=0; row < ConnectFourArray.length; row++ ){
System.out.print("Row " + row + ": ");
for ( int col=0; col < ConnectFourArray[row].length; col++ )
System.out.print( ConnectFourArray[row][col] + " ");
System.out.println();
System.out.println();
System.out.println ("Please Select a column of 0 through 6 ");
column1 = selecter.readLine();
num1= Integer.parseInt(column1);
System.out.println();
if (num1==0){
ConnectFourArray[cup0][0]=2;
cup0=cup0-1;
else if (num1==1){
ConnectFourArray[cup1][1]=2;
cup1=cup1-1;
else if (num1==2){
ConnectFourArray[cup2][2]=2;
cup2=cup2-1;
else if (num1==3){
ConnectFourArray[cup3][3]=2;
cup3=cup3-1;
else if (num1==4){
ConnectFourArray[cup4][4]=2;
cup4=cup4-1;
else if (num1==5){
ConnectFourArray[cup5][5]=2;
cup5=cup5-1;
else if (num1==6){
ConnectFourArray[cup6][6]=2;
cup6=cup6-1;
System.out.println();
System.out.println();
catch (Exception E){
System.out.println("Error with input");
System.out.println("Would you like to play again");
try{
String value;
BufferedReader reader = new BufferedReader (new InputStreamReader(System.in));
// Scanner scan = new Scanner(System.in);
System.out.println("Enter yes to play or no to quit");
// value = scan.nextLine();
// String value2;
value = reader.readLine();
//value2 = reader.readLine();
if (value.equals("yes"))
System.out.println("Start again");
StartGame(); // calling the StartGame method to play a game once more
else if (value.equals("no"))
System.out.println("No more games to play");
// System.exit(0);
else
System.exit(0);
System.out.println();
catch (Exception e){
System.out.println("Error with input");
finally
System.out.println(" playing done");
//StartGame();
//check for horizontal win
public int hasWon()
int status = 0;
for (int row=0; row<6; row++)
for (int col=0; col<4; col++)
if (ConnectFourArray[col][row] != 0 &&
ConnectFourArray[col][row] == ConnectFourArray[col+1][row] &&
ConnectFourArray[col][row] == ConnectFourArray[col+2][row] &&
ConnectFourArray[col][row] == ConnectFourArray[col+3][row])
//status = true;//int winner;
if(status == player1)
System.out.println("Player 1 is the winner");
else if(status == player2)
System.out.println("Player 2 is the winner" );
}//end inner for loop
}// end outer for loop
} // end method Winner
return status;
}//end class
ClassConnectFour which designs the board........................
import java.util.*;
import java.io.*;
import javax.swing.*;
public class ClassConnectFour
//Player player1;
//Player player2;
public ClassConnectFour()
//this.player1 = player1;
public void DrawBoard()
int[][] ConnectFourArray = new int[6][7] ;
for ( int row=0; row < ConnectFourArray.length; row++ ){
System.out.print("Row " + row + ": ");
for ( int col=0; col < ConnectFourArray[row].length; col++ )
System.out.print( ConnectFourArray[row][col] + " ");
System.out.println();
System.out.println();
}//end class
TestConnetFour class which uses most of the above class..................
import java.util.*;
import java.io.*;
import javax.swing.*;
public class TestConnectFour
public static void main(String[] args)
ClassConnectFour cf = new ClassConnectFour();
cf.DrawBoard();
Player1 player1 = new Player1();
Player2 player2 = new Player2();
player1.move();
player2.move();
System.out.println("Number 1 belongs to player " + player1.name());
System.out.println("Number 2 belongs to player " + player2.name());
PlayGame pg = new PlayGame();
pg.StartGame();
pg.hasWon();
//pg.Play();
//System.out.println(player.name());
//System.out.println(player2.name());
}// end main
}//end classI am sorry for all this junk code but I only understand it this way. Your urgent help is required. Looking forward to your reply.
Thanks in advance.
Koonda -
hi friends,
Help me how to do this
REPORT ZINTERFACE_SAMPLE.
type-pools:SLIS.
TABLES:knb1, "Customer Master (Company Code)
kna1,
knvp. "Customer Master Partner Functions
TYPES:BEGIN OF T_knb1,
kunnr like knb1-kunnr,
bukrs like knb1-bukrs,
akont like knb1-akont,
END OF T_knb1.
TYPES:BEGIN OF T_kna1,
kunnr like kna1-kunnr, "customer number
NAME1 like KNA1-NAME1, "customer name
stras like KNA1-STRAS, "Customer address
ort01 like KNA1-ORT01, "Customer city
stcd1 like KNA1-STCD1, "Tax id
pstlz like KNA1-PSTLZ, "Postal code
END OF T_kna1.
TYPES:BEGIN OF T_knvp,
kunnr like knvp-kunnr, "customer number
parvw like knvp-parvw,
kunn2 like knvp-kunn2, "Customer number of business partner
END OF T_KNVP.
TYPES:BEGIN OF T_final,
Record_type TYPE c,
Sold_to_cust(10) TYPE c,
Payer(10) TYPE c,
Sequence(5) TYPE n,
Cust_name(35) TYPE c,
Cust_adreess(35) TYPE c,
Cust_city(35) TYPE c,
Tax_id(16) TYPE c,
Postal_code(5) TYPE c,
Branch TYPE c,
Delivery(3) TYPE c,
END OF T_final.
*Internal table declaration
DATA:I_knb1 TYPE STANDARD TABLE OF t_knb1 initial size 0,
i_kna1 TYPE STANDARD TABLE OF t_kna1 initial size 0,
i_knvp TYPE STANDARD TABLE OF t_knvp initial size 0,
i_final TYPE STANDARD TABLE OF t_final initial size 0.
DATA: t_fieldcat_tab TYPE slis_t_fieldcat_alv WITH HEADER LINE.
*Work area declaration
DATA:wa_knb1 TYPE t_knb1,
wa_kna1 TYPE t_kna1,
wa_knvp TYPE t_knvp,
wa_final TYPE t_final.
*variable declaration
data:sequence TYPe n,
g_line TYPE i.
selection screen *
SELECTION-screen begin of block b1 with frame title text-001.
parameters:p_bukrs like knb1-bukrs, "Company code
p_akont like knb1-akont .
selection-screen end of block b1.
SELECTION-screen begin of block b2 with frame title text-002.
PARAMETERS:R1 RADIOBUTTON GROUP G1,
R2 RADIOBUTTON GROUP G1.
Parameters:p_file like rlgrap-filename.
"Recon Account in General Ledger
selection-screen end of block b2.
*AT selection-screen ON VALUE-REQUEST FOR P_FILE.
CALL FUNCTION 'F4_FILENAME'
IMPORTING
FILE_NAME = P_FILE.
START-OF-selection.
PERFORM f_fetchdata.
PERFORM f_prepare_fieldcat.
PERFORM f_display_report.
*END-OF-SELECTION.
*IF R1 EQ 'X'.
*perform F_DOWNLOAD.
*ENDIF.
*IF R2 EQ 'X'.
*OPEN DATASET P_FILE FOR OUTPUT IN text mode ENCODING DEFAULT.
*LOOP AT i_final INTO WA_final.
*TRANSFER WA_final TO P_FILE.
*ENDLOOP.
*CLOSE DATASET P_FILE.
*ENDIF.
*& Form f_fetchdata
FORM f_fetchdata .
select kunnr
bukrs
akont
from knb1
into table i_knb1
where bukrs = p_bukrs
AND akont = p_akont.
DESCRIBE TABLE i_knb1 LINES g_line.
LOOP AT i_knb1 INTO wa_knb1.
SELECT single KUNNR
NAME1
STRAS
ORT01
STCD1
PSTLZ
FROM kna1
INTO wa_kna1
where kunnr = wa_knb1-kunnr.
if sy-subrc <> 0.
*Error KNA1 record not found.
endif.
SELECT single kunnr
parvw
kunn2
FROM KNVP
INTO wa_knvp
where kunnr = wa_knb1-kunnr
AND parvw = 'RG'.
if sy-subrc <> 0.
*Error KNA1 record not found.
endif.
sequence = sequence + 1.
MOVE: 'c' TO wa_final-Record_type,
wa_knvp-kunnr TO wa_final-Sold_to_cust,
sequence TO wa_final-Sequence,
wa_KNA1-NAME1 TO wa_final-Cust_name,
wa_kna1-STRAS TO wa_final-Cust_adreess ,
wa_kna1-ort01 TO wa_final-Cust_city,
wa_kna1-STCD1 TO wa_final-Tax_id,
wa_kna1-PSTLZ TO wa_final-Postal_code,
'1' TO wa_final-branch,
'abc' TO wa_final-Delivery.
INSERT wa_final INTO TABLE i_final.
endloop.
ENDFORM. " f_fetchdata
FORM f_prepare_fieldcat.
t_fieldcat_tab-col_pos = 1.
t_fieldcat_tab-tabname = 'i_final'.
t_fieldcat_tab-fieldname = 'Record_type'.
t_fieldcat_tab-seltext_l = 'Record type'.
APPEND t_fieldcat_tab.
t_fieldcat_tab-col_pos = 2.
t_fieldcat_tab-tabname = 'i_final'.
t_fieldcat_tab-fieldname = 'Sold_to_cust'.
t_fieldcat_tab-seltext_l = 'Sold to cust'.
APPEND t_fieldcat_tab.
t_fieldcat_tab-col_pos = 3.
t_fieldcat_tab-tabname = 'i_final'.
t_fieldcat_tab-fieldname = 'payer'.
t_fieldcat_tab-seltext_l = 'Payer'.
APPEND t_fieldcat_tab.
t_fieldcat_tab-col_pos = 4.
t_fieldcat_tab-tabname = 'i_final'.
t_fieldcat_tab-fieldname = 'Sequence'.
t_fieldcat_tab-seltext_l = 'sequence'.
APPEND t_fieldcat_tab.
t_fieldcat_tab-col_pos = 5.
t_fieldcat_tab-tabname = 'i_final'.
t_fieldcat_tab-fieldname = 'Cust_name'.
t_fieldcat_tab-seltext_l = 'Cust name'.
APPEND t_fieldcat_tab.
t_fieldcat_tab-col_pos = 6.
t_fieldcat_tab-tabname = 'i_final'.
t_fieldcat_tab-fieldname = 'Cust_adreess'.
t_fieldcat_tab-seltext_l = 'Cust adreess'.
APPEND t_fieldcat_tab.
t_fieldcat_tab-col_pos = 7.
t_fieldcat_tab-tabname = 'i_final'.
t_fieldcat_tab-fieldname = 'Cust_city'.
t_fieldcat_tab-seltext_l = 'Cust city'.
APPEND t_fieldcat_tab.
t_fieldcat_tab-col_pos = 8.
t_fieldcat_tab-tabname = 'i_final'.
t_fieldcat_tab-fieldname = 'Tax_id'.
t_fieldcat_tab-seltext_l = 'Tax id'.
APPEND t_fieldcat_tab.
t_fieldcat_tab-col_pos = 9.
t_fieldcat_tab-tabname = 'i_final'.
t_fieldcat_tab-fieldname = 'Postal_code'.
t_fieldcat_tab-seltext_l = 'Postal code'.
APPEND t_fieldcat_tab.
t_fieldcat_tab-col_pos = 10.
t_fieldcat_tab-tabname = 'i_final'.
t_fieldcat_tab-fieldname = 'Branch'.
t_fieldcat_tab-seltext_l = 'Branch'.
APPEND t_fieldcat_tab.
t_fieldcat_tab-col_pos = 11.
t_fieldcat_tab-tabname = 'i_final'.
t_fieldcat_tab-fieldname = 'KWMENG'.
t_fieldcat_tab-seltext_l = 'Order Qty'.
APPEND t_fieldcat_tab.
t_fieldcat_tab-col_pos = 12.
t_fieldcat_tab-tabname = 'i_final'.
t_fieldcat_tab-fieldname = 'Delivery'.
t_fieldcat_tab-seltext_l = 'Delivery'.
APPEND t_fieldcat_tab.
ENDFORM. " f_prepare_fieldcat
*& Form f_display_report
*To display the ALV Report
FORM f_display_report.
DATA: l_repid LIKE sy-repid.
l_repid = sy-repid.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = l_repid
i_buffer_active = 'X'
IT_FIELDCAT = t_fieldcat_tab[]
I_DEFAULT = 'X'
I_SAVE = 'A'
TABLES
T_OUTTAB = i_final[].
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM." f_display_report
*& Form F_DOWNLOAD
text
--> p1 text
<-- p2 text
FORM F_DOWNLOAD .
*CALL FUNCTION 'WS_DOWNLOAD'
EXPORTING
FILENAME = p_file
FILETYPE = 'ASC'
MODE = ' '
WK1_N_FORMAT = ' '
WK1_N_SIZE = ' '
WK1_T_FORMAT = ' '
WK1_T_SIZE = ' '
COL_SELECT = ' '
COL_SELECTMASK = ' '
NO_AUTH_CHECK = ' '
IMPORTING
FILELENGTH =
TABLES
DATA_TAB = i_final
EXCEPTIONS
FILE_OPEN_ERROR = 1
FILE_WRITE_ERROR = 2
INVALID_FILESIZE = 3
INVALID_TYPE = 4
NO_BATCH = 5
UNKNOWN_ERROR = 6
INVALID_TABLE_WIDTH = 7
GUI_REFUSE_FILETRANSFER = 8
CUSTOMER_ERROR = 9
NO_AUTHORITY = 10
OTHERS = 11
*IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
*ENDIF.
ENDFORM. " F_DOWNLOAD
for this one when i given the proper input
it showing the Runtime error.
Could u please tell me what mistake i have done
Urgent help
Regards
harshavi N.HI,
Run this program..
REPORT ZINTERFACE_SAMPLE.
type-pools:SLIS.
TABLES:knb1, "Customer Master (Company Code)
kna1,
knvp. "Customer Master Partner Functions
TYPES:BEGIN OF T_knb1,
kunnr like knb1-kunnr,
bukrs like knb1-bukrs,
akont like knb1-akont,
END OF T_knb1.
TYPES:BEGIN OF T_kna1,
kunnr like kna1-kunnr, "customer number
NAME1 like KNA1-NAME1, "customer name
stras like KNA1-STRAS, "Customer address
ort01 like KNA1-ORT01, "Customer city
stcd1 like KNA1-STCD1, "Tax id
pstlz like KNA1-PSTLZ, "Postal code
END OF T_kna1.
TYPES:BEGIN OF T_knvp,
kunnr like knvp-kunnr, "customer number
parvw like knvp-parvw,
kunn2 like knvp-kunn2, "Customer number of business partner
END OF T_KNVP.
TYPES:BEGIN OF T_final,
Record_type TYPE c,
Sold_to_cust(10) TYPE c,
Payer(10) TYPE c,
Sequence(5) TYPE n,
Cust_name(35) TYPE c,
Cust_adreess(35) TYPE c,
Cust_city(35) TYPE c,
Tax_id(16) TYPE c,
Postal_code(5) TYPE c,
Branch TYPE c,
Delivery(3) TYPE c,
END OF T_final.
*Internal table declaration
DATA:I_knb1 TYPE STANDARD TABLE OF t_knb1 initial size 0,
i_kna1 TYPE STANDARD TABLE OF t_kna1 initial size 0,
i_knvp TYPE STANDARD TABLE OF t_knvp initial size 0,
i_final TYPE STANDARD TABLE OF t_final initial size 0.
DATA: t_fieldcat_tab TYPE slis_t_fieldcat_alv WITH HEADER LINE.
*Work area declaration
DATA:wa_knb1 TYPE t_knb1,
wa_kna1 TYPE t_kna1,
wa_knvp TYPE t_knvp,
wa_final TYPE t_final.
*variable declaration
data:sequence TYPe n,
g_line TYPE i.
selection screen *
SELECTION-screen begin of block b1 with frame title text-001.
parameters:p_bukrs like knb1-bukrs, "Company code
p_akont like knb1-akont .
selection-screen end of block b1.
SELECTION-screen begin of block b2 with frame title text-002.
PARAMETERS:R1 RADIOBUTTON GROUP G1,
R2 RADIOBUTTON GROUP G1.
Parameters:p_file like rlgrap-filename.
"Recon Account in General Ledger
selection-screen end of block b2.
*AT selection-screen ON VALUE-REQUEST FOR P_FILE.
CALL FUNCTION 'F4_FILENAME'
IMPORTING
FILE_NAME = P_FILE.
START-OF-selection.
PERFORM f_fetchdata.
PERFORM f_prepare_fieldcat.
PERFORM f_display_report.
*END-OF-SELECTION.
*IF R1 EQ 'X'.
*perform F_DOWNLOAD.
*ENDIF.
*IF R2 EQ 'X'.
*OPEN DATASET P_FILE FOR OUTPUT IN text mode ENCODING DEFAULT.
*LOOP AT i_final INTO WA_final.
*TRANSFER WA_final TO P_FILE.
*ENDLOOP.
*CLOSE DATASET P_FILE.
*ENDIF.
*& Form f_fetchdata
FORM f_fetchdata .
select kunnr
bukrs
akont
from knb1
into table i_knb1
where bukrs = p_bukrs
AND akont = p_akont.
DESCRIBE TABLE i_knb1 LINES g_line.
LOOP AT i_knb1 INTO wa_knb1.
SELECT single KUNNR
NAME1
STRAS
ORT01
STCD1
PSTLZ
FROM kna1
INTO wa_kna1
where kunnr = wa_knb1-kunnr.
if sy-subrc <> 0.
*Error KNA1 record not found.
endif.
SELECT single kunnr
parvw
kunn2
FROM KNVP
INTO wa_knvp
where kunnr = wa_knb1-kunnr
AND parvw = 'RG'.
if sy-subrc <> 0.
*Error KNA1 record not found.
endif.
sequence = sequence + 1.
MOVE: 'c' TO wa_final-Record_type,
wa_knvp-kunnr TO wa_final-Sold_to_cust,
sequence TO wa_final-Sequence,
wa_KNA1-NAME1 TO wa_final-Cust_name,
wa_kna1-STRAS TO wa_final-Cust_adreess ,
wa_kna1-ort01 TO wa_final-Cust_city,
wa_kna1-STCD1 TO wa_final-Tax_id,
wa_kna1-PSTLZ TO wa_final-Postal_code,
'1' TO wa_final-branch,
'abc' TO wa_final-Delivery.
INSERT wa_final INTO TABLE i_final.
endloop.
ENDFORM. " f_fetchdata
FORM f_prepare_fieldcat.
t_fieldcat_tab-col_pos = 1.
t_fieldcat_tab-tabname = 'I_FINAL'.
t_fieldcat_tab-fieldname = 'RECORD_TYPE'.
t_fieldcat_tab-seltext_l = 'Record type'.
APPEND t_fieldcat_tab.
t_fieldcat_tab-col_pos = 2.
t_fieldcat_tab-tabname = 'I_FINAL'.
t_fieldcat_tab-fieldname = 'SOLD_TO_CUST'.
t_fieldcat_tab-seltext_l = 'Sold to cust'.
APPEND t_fieldcat_tab.
t_fieldcat_tab-col_pos = 3.
t_fieldcat_tab-tabname = 'I_FINAL'.
t_fieldcat_tab-fieldname = 'PAYER'.
t_fieldcat_tab-seltext_l = 'Payer'.
APPEND t_fieldcat_tab.
t_fieldcat_tab-col_pos = 4.
t_fieldcat_tab-tabname = 'I_FINAL'.
t_fieldcat_tab-fieldname = 'SEQUENCE'.
t_fieldcat_tab-seltext_l = 'sequence'.
APPEND t_fieldcat_tab.
t_fieldcat_tab-col_pos = 5.
t_fieldcat_tab-tabname = 'I_FINAL'.
t_fieldcat_tab-fieldname = 'CUST_NAME'.
t_fieldcat_tab-seltext_l = 'Cust name'.
APPEND t_fieldcat_tab.
t_fieldcat_tab-col_pos = 6.
t_fieldcat_tab-tabname = 'I_FINAL'.
t_fieldcat_tab-fieldname = 'CUST_ADREESS'.
t_fieldcat_tab-seltext_l = 'Cust adreess'.
APPEND t_fieldcat_tab.
t_fieldcat_tab-col_pos = 7.
t_fieldcat_tab-tabname = 'I_FINAL'.
t_fieldcat_tab-fieldname = 'CUST_CITY'.
t_fieldcat_tab-seltext_l = 'Cust city'.
APPEND t_fieldcat_tab.
t_fieldcat_tab-col_pos = 8.
t_fieldcat_tab-tabname = 'I_FINAL'.
t_fieldcat_tab-fieldname = 'TAX_ID'.
t_fieldcat_tab-seltext_l = 'Tax id'.
APPEND t_fieldcat_tab.
t_fieldcat_tab-col_pos = 9.
t_fieldcat_tab-tabname = 'I_FINAL'.
t_fieldcat_tab-fieldname = 'POSTAL_CODE'.
t_fieldcat_tab-seltext_l = 'Postal code'.
APPEND t_fieldcat_tab.
t_fieldcat_tab-col_pos = 10.
t_fieldcat_tab-tabname = 'I_FINAL'.
t_fieldcat_tab-fieldname = 'BRANCH'.
t_fieldcat_tab-seltext_l = 'Branch'.
APPEND t_fieldcat_tab.
t_fieldcat_tab-col_pos = 11.
t_fieldcat_tab-tabname = 'I_FINAL'.
t_fieldcat_tab-fieldname = 'KWMENG'.
t_fieldcat_tab-seltext_l = 'Order Qty'.
APPEND t_fieldcat_tab.
t_fieldcat_tab-col_pos = 12.
t_fieldcat_tab-tabname = 'I_FINAL'.
t_fieldcat_tab-fieldname = 'DELIVERY'.
t_fieldcat_tab-seltext_l = 'Delivery'.
APPEND t_fieldcat_tab.
ENDFORM. " f_prepare_fieldcat
*& Form f_display_report
*To display the ALV Report
FORM f_display_report.
DATA: l_repid LIKE sy-repid.
l_repid = sy-repid.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = l_repid
IT_FIELDCAT = t_fieldcat_tab[]
I_DEFAULT = 'X'
I_SAVE = 'A'
TABLES
T_OUTTAB = I_FINAL[].
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM." f_display_report
*& Form F_DOWNLOAD
text
--> p1 text
<-- p2 text
FORM F_DOWNLOAD .
*CALL FUNCTION 'WS_DOWNLOAD'
EXPORTING
FILENAME = p_file
FILETYPE = 'ASC'
MODE = ' '
WK1_N_FORMAT = ' '
WK1_N_SIZE = ' '
WK1_T_FORMAT = ' '
WK1_T_SIZE = ' '
COL_SELECT = ' '
COL_SELECTMASK = ' '
NO_AUTH_CHECK = ' '
IMPORTING
FILELENGTH =
TABLES
DATA_TAB = i_final
EXCEPTIONS
FILE_OPEN_ERROR = 1
FILE_WRITE_ERROR = 2
INVALID_FILESIZE = 3
INVALID_TYPE = 4
NO_BATCH = 5
UNKNOWN_ERROR = 6
INVALID_TABLE_WIDTH = 7
GUI_REFUSE_FILETRANSFER = 8
CUSTOMER_ERROR = 9
NO_AUTHORITY = 10
OTHERS = 11
*IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
*ENDIF.
ENDFORM. " F_DOWNLOAD
It is perfectly working for me..
I made the field name and table name as CAPs in the field catalog internal table.
I removed the buffer paramter in the ALV FM.
Thanks,
Naren
Maybe you are looking for
-
I recently switched the sim card in my iPhone when I moved from one country to another. When I put my local sim card in iMessage would not activate (just staying on 'waiting for activation' forever). This has not been a problem before. When I went to
-
How to run Windows on top of Linux
Just an idea for those of you who are using Linux but still need to run Windows XP or Vista for one reason or another. When I bought my machine, I immediately reformatted the HD getting rid of Vista and all of that other prebundeled junk that made my
-
In ALV O/p , need Editable Checkbox for particular cell based on signal lig
Hi, I have requiremnt liek this in my ALV There are 4 records in the output consisting of fields checkbox , traffic lights. here, 2 are Red and 2 are Green. now Green light checkboxes should be (Enabled mode)checked with Edit mode. Red light check bo
-
Cannot locate Safari toolbar - specifically trying to find VIEW using windows
Cannot locate Safari toolbar - it disappeared. My seach has said to find the View but it is not on my toolbar. I am using windows 7.
-
"Scale to fit paper size" ......doesn't
It's often convenient to scale a web page down to fit the entire page on letter size. This is doable with the Scale field in the print dialog box. On the other hand, I can't get Paper Handling>"Scale to fit paper size" to work in Safari. It works in