How to call comments from purchase header in a report

aliennavaliennav Member Posts: 449
Hi All
How to call comments from purchase header in a report--Purchase order report??
I want to call it in an integer data item.
I tried using setrange on document type and No. but it didn't work.
Kindly tell me asap.
Thanx

Comments

  • garakgarak Member Posts: 3,263
    new DataItem over table "Purch. Comment Line". Link this dataItem with your Header (for linking see the RunFormLink behind the Comment CommandButton on Purch. Order.

    Regards
    Do you make it right, it works too!
  • AlbertvhAlbertvh Member Posts: 516
    Hi

    Use table 43 Purch. Comment Line


    Albert
  • aliennavaliennav Member Posts: 449
    Albertvh wrote:
    Hi

    Use table 43 Purch. Comment Line


    Albert

    I forgot to tell u but I am using "Purch. Comment Line".
    I am using setrange b/w "document no." of Purch. Comment line and "No." of Purchase header and I have created a text type variable on report and I am putting the value of "Purch. Comment Line".Comments in the text type field that I have created.

    But,I am not able to print it .
    Can u suggest the code??
  • AlbertvhAlbertvh Member Posts: 516
    Hi

    I take it you have something like this

    Purchase Header
    -Purchase Line
    -Purch. Comment Line

    in the properties of Purch. Comment Line set the DataItemLink to
    Document Type to Purchase Header Document Type
    No. to Purchase Header No.

    Hope this helps

    Albert
  • garakgarak Member Posts: 3,263
    Do you knwo how to programming / design Reports :?:
    Do you make it right, it works too!
  • aliennavaliennav Member Posts: 449
    Albertvh wrote:
    Hi

    I take it you have something like this

    Purchase Header
    -Purchase Line
    -Purch. Comment Line

    in the properties of Purch. Comment Line set the DataItemLink to
    Document Type to Purchase Header Document Type
    No. to Purchase Header No.

    Hope this helps

    Albert
    Thanx 4 the solution but i don't want to declare a new data item.I want to do it by declaring a datatype record for "Purch. Comment Line."
    I hope u understand.
  • AlbertvhAlbertvh Member Posts: 516
    Well if your comments are all 1 liners there is no problem but if there is more than one how are you going to print these?

    OnAfterGetRecord of Purchase Header

    PurchCommentLine.SETRANGE("Document Type","Document Type");
    PurchCommentLine.SETRANGE("No.","No.");
    IF NOT PurchCommentLine.FINDFIRST THEN
    CLEAR(PurchCommentLine);



    Albert
  • Sandeep_PrajapatiSandeep_Prajapati Member Posts: 151
    i don't want to declare a new data item
    why dear...?? :?:
    Sandeep Prajapati
    Technical Consultant, MS Dynamics NAV
  • aliennavaliennav Member Posts: 449
    i don't want to declare a new data item
    why dear...?? :?:

    According to technical standards u should first try to declare a data item.

    Also,for printing 1 field we should'nt create a dataitem.

    If I am wrong please correct me.
    Thanx
  • Sandeep_PrajapatiSandeep_Prajapati Member Posts: 151
    According to technical standards u should first try to declare a data item.
    I am really not aware of this standard. If you can give a reference for that or put your Idea for that cogently, It would be really great. :-k
    I would suggest that dataItem is more faster and cleaner way of scanning records from a table and printing them in the section of reports. [-(
    Also,for printing 1 field we should'nt create a dataitem.
    Based on the assumption that you never have more than one comment lines for purchase line, using a rec variable for purch. comment line is OK.
    however if we can not assume that,....though that can be handeled in an unclean way, using a rec variable is not at all suggestable. [-(
    Sandeep Prajapati
    Technical Consultant, MS Dynamics NAV
  • Sandeep_PrajapatiSandeep_Prajapati Member Posts: 151
    According to technical standards u should first try to declare a data item.
    Can the knowledgable people over here share their valuable thoughts on this please.
    Sandeep Prajapati
    Technical Consultant, MS Dynamics NAV
  • aliennavaliennav Member Posts: 449
    According to technical standards u should first try to declare a data item.
    Can the knowledgable people over here share their valuable thoughts on this please.

    Sorry it ws a mistake.
    first we should try to create a variable.

    Sorry
  • XypherXypher Member Posts: 297
    Hey aliennav,

    If I may ask, when you attempted to use an Integer DataItem to list the, possible several, comments what kind of output were you getting?
  • SavatageSavatage Member Posts: 7,142
    You call it just a field but it could be 1 line or 100 lines.
    As stated above - how many comment lines do you want to be able to handle?
  • aliennavaliennav Member Posts: 449
    I want to print several lines for a single purchase header
  • aliennavaliennav Member Posts: 449
    Hi
    I am now facing the problem of printing single line and multiple lines.
    Singles are printed but multiples are not(only 1st was printed.)
    Shall i try "on after getrecord "for purchase header .
    Suggest me something.
    Thanx
  • SavatageSavatage Member Posts: 7,142
    Here's how we add 10 comment lines to our picking ticket - the same method can be used for a puchase order report.

    Use array to store your comments and display each line of the array n a different header section.

    see this for better idea.
    http://savatage99.googlepages.com/10153 ... yOrder.txt
  • aliennavaliennav Member Posts: 449
    Savatage wrote:
    Here's how we add 10 comment lines to our picking ticket - the same method can be used for a puchase order report.

    Use array to store your comments and display each line of the array n a different header section.

    see this for better idea.
    http://savatage99.googlepages.com/10153 ... yOrder.txt

    I dont think that calling multiple line comments on a report is that complex.
  • SavatageSavatage Member Posts: 7,142
    it's not that complex - it you import thr report you will see plus you said "Suggest me something. "
    :mrgreen:
  • aliennavaliennav Member Posts: 449
    Savatage wrote:
    it's not that complex - it you import thr report you will see plus you said "Suggest me something. "
    :mrgreen:

    I am really thakful for your suggestion BUT can I get some easier way 2 do it?
  • Sandeep_PrajapatiSandeep_Prajapati Member Posts: 151
    Hi aliennav,

    Do you mean ....an easier way without using a purch. comment line DataItem ... :?:
    Sandeep Prajapati
    Technical Consultant, MS Dynamics NAV
  • SavatageSavatage Member Posts: 7,142
    if you want 1 line then it's easy
    if you want a number of possible comments lines then the complexity is increased. Just the way it is.

    you add the sales comment line as a dataitem link to the sales header
    OnPreDataItem()
    FOR i := 1 TO 10 DO
      CommentText[i] := '';
    i:= 0;
    
    OnAfterGetRecord()
    i := i + 1;
    CommentText[i] :=
      '******************************************************************************************************************';
    IF (STRLEN(Comment) < STRLEN(CommentText[i])) THEN
      CommentText[i] := Comment + COPYSTR(CommentText[i],1,(STRLEN(CommentText[i]) - STRLEN(Comment)))
    ELSE
      CommentText[i] := Comment;
    

    View Sections , create pageloop header
    OnPreSection()
    IF CommentText[1] = '' THEN
      CurrReport.SHOWOUTPUT := FALSE;
    
    on the next section
    OnPreSection()
    IF CommentText[2] = '' THEN
      CurrReport.SHOWOUTPUT := FALSE;
    etc 
    etc.
    

    I guess you could hard code it with variables. :-k
    PurchComment.SETCURRENTKEY(..fill in..);
    PurchComment.SETFILTER(...fill in..);
    
    IF PurchComment.FIND('-') THEN
      REPEAT
         IF PurchComment."Line No." = 10000 THEN text1 := PurchComment.Textline;
         IF PurchComment."Line No." = 20000 THEN text2 := PurchComment.Textline;
         IF PurchComment."Line No." = 30000 THEN text3 := PurchComment.Textline;
         IF PurchComment."Line No." = 40000 THEN text4 := PurchComment.Textline;
         IF PurchComment."Line No." = 50000 THEN text5 := PurchComment.Textline;
         IF PurchComment."Line No." = 60000 THEN text6 := PurchComment.Textline;
         IF PurchComment."Line No." = 70000 THEN text7 := PurchComment.Textline;
         IF PurchComment."Line No." = 80000 THEN text8 := PurchComment.Textline;
         IF PurchComment."Line No." = 90000 THEN text9 := PurchComment.Textline;
         IF PurchComment."Line No." = 100000 THEN text10 := PurchComment.Textline;
        UNTIL PurchComment.NEXT=0;
    END;
    

    Ok now you have 10 lines of comments all in different text variables from text1 to text10
    you can now add these fields to a section.

    I still like the array method. note this method requires you to force a number of lines unless you want to get crazy and add 100
  • couberpucouberpu Member Posts: 317
    Sorry! I have to add a stupid question here:

    How about the spacing of the report output? Is there a way to make the section grow and shrink based on number of comment lines?
  • SavatageSavatage Member Posts: 7,142
    http://savatage99.googlepages.com/10153 ... yOrder.txt
    Rename OBJECT Report 10153 Picking List by Order
    to a number you have avaialable

    if you import the report you will see each array[x]
    is on it's own line and if the line is blank the showoutput is false.
    I guess you can do this too for the hardcoded one.

    Note that it's a pageloop based on the header
    loop1..
    Main header
    loop2..
    Header comment1
    loop3..
    header comment 2
    loop4..
    header comment 3
    etc
    etc
    IF CommentText[1] = '' THEN 
      CurrReport.SHOWOUTPUT := FALSE;
    

    if i have a sec i'll move it to a purch report.
  • SavatageSavatage Member Posts: 7,142
    ok here is a purchase order report with 10 lines of possible comments
    http://savatage99.googlepages.com/50072 ... mments.txt
    here's a fob it you can't import the text file
    http://savatage99.googlepages.com/50072 ... mments.fob

    Only took a min or two so it's not that complicated.

    the report is designed to
    ->Print the header
    -->Print 1 to 10 comment lines
    --->print purchase lines
  • aliennavaliennav Member Posts: 449
    Savatage wrote:
    if you want 1 line then it's easy
    if you want a number of possible comments lines then the complexity is increased. Just the way it is.

    you add the sales comment line as a dataitem link to the sales header
    OnPreDataItem()
    FOR i := 1 TO 10 DO
      CommentText[i] := '';
    i:= 0;
    
    OnAfterGetRecord()
    i := i + 1;
    CommentText[i] :=
      '******************************************************************************************************************';
    IF (STRLEN(Comment) < STRLEN(CommentText[i])) THEN
      CommentText[i] := Comment + COPYSTR(CommentText[i],1,(STRLEN(CommentText[i]) - STRLEN(Comment)))
    ELSE
      CommentText[i] := Comment;
    

    View Sections , create pageloop header
    OnPreSection()
    IF CommentText[1] = '' THEN
      CurrReport.SHOWOUTPUT := FALSE;
    
    on the next section
    OnPreSection()
    IF CommentText[2] = '' THEN
      CurrReport.SHOWOUTPUT := FALSE;
    etc 
    etc.
    

    I guess you could hard code it with variables. :-k
    PurchComment.SETCURRENTKEY(..fill in..);
    PurchComment.SETFILTER(...fill in..);
    
    IF PurchComment.FIND('-') THEN
      REPEAT
         IF PurchComment."Line No." = 10000 THEN text1 := PurchComment.Textline;
         IF PurchComment."Line No." = 20000 THEN text2 := PurchComment.Textline;
         IF PurchComment."Line No." = 30000 THEN text3 := PurchComment.Textline;
         IF PurchComment."Line No." = 40000 THEN text4 := PurchComment.Textline;
         IF PurchComment."Line No." = 50000 THEN text5 := PurchComment.Textline;
         IF PurchComment."Line No." = 60000 THEN text6 := PurchComment.Textline;
         IF PurchComment."Line No." = 70000 THEN text7 := PurchComment.Textline;
         IF PurchComment."Line No." = 80000 THEN text8 := PurchComment.Textline;
         IF PurchComment."Line No." = 90000 THEN text9 := PurchComment.Textline;
         IF PurchComment."Line No." = 100000 THEN text10 := PurchComment.Textline;
        UNTIL PurchComment.NEXT=0;
    END;
    

    Ok now you have 10 lines of comments all in different text variables from text1 to text10
    you can now add these fields to a section.

    I still like the array method. note this method requires you to force a number of lines unless you want to get crazy and add 100





    Thanx ma'an
    The idea is pretty good
  • SavatageSavatage Member Posts: 7,142
    Savatage wrote:
    ok here is a purchase order report with 10 lines of possible comments
    http://savatage99.googlepages.com/50072 ... mments.txt
    here's a fob it you can't import the text file
    http://savatage99.googlepages.com/50072 ... mments.fob

    Only took a min or two so it's not that complicated.

    the report is designed to
    ->Print the header
    -->Print 1 to 10 comment lines
    --->print purchase lines

    did you download & look at this?
  • aliennavaliennav Member Posts: 449
    wat is "PurchCommentLine.Textline" in the code u suggested?
  • aliennavaliennav Member Posts: 449
    The report u gave here for downloading is running fine.
    Thanx
Sign In or Register to comment.