Skip to Content

Header / Line Item in Printing Forms

Dear all,

I'm struggling with an issue in taking the values from the line item and putting into the header of the form. Can you please help me out with the scripting?

I hope the requirement is clear, please let  me know if it isn't..

Form Header:

Form Detail (also Content Area):

This is the ITAB coming into the form.

Based on the combination of WERKS and LGORT(Storage Location),  I need to create a  new page. I have achieved this using Conditional break and it's working fine. If there are more line items and it exceeds the content area, it flows to the next page, no issues here as well.

So the output will look like below for the example given above.

So the question here is, I need to take the first LGORT on the given page and display it on header (each page will have header and Detail). So the first page will have no storgage location (LGORT) in header, the second page will have 0720 as storage location (LGORT) in header and the third page will have 0900 as storage location (LGORT) in header.

Basically what I want is in the content area the first DATA elements LGORT on each page. How can I get this?

I apologize if I wasn't clear on the requirement. Sincerely appreciate your time and effort!

Thank you,

Justin.

Capture1.PNG (14.1 kB)
Capture6.PNG (3.0 kB)
Capture5.PNG (6.0 kB)
Capture2.PNG (6.1 kB)
Capture3.PNG (3.9 kB)
Capture4.PNG (7.8 kB)
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

4 Answers

  • Best Answer
    Oct 04, 2015 at 06:29 PM

    Hello Piyush,

    I just wanted to update you and get opinion. I finally got it working through Coding in the Interface (Code Initialization). The below coding will work in conjunction with the content area (assuming that no one else will increase the content area). I have run it and in a given page I can have maximum of 9 line items (DATA[*]) in a given page, rest data will flow to the next page. I have taken the same coding in Conditional Editor and with the content area limit , I'm generating the GT_LGORT_HDR table. The ITAB will have exact no.of LGORT for each page.

    LOOP AT GT_VBLKP INTO GS_VBLKP.
      LV_COUNTER = LV_COUNTER + 1.
      IF SY-TABIX = 1.
        LS_LGORT-LGORT = GS_VBLKP-LGORT.
        APPEND LS_LGORT TO LT_LGORT.
      ELSE.
        IF LV_COUNTER = 9 OR LV_LGORT <> GS_VBLKP-LGORT OR LV_WERKS <> GS_VBLKP-WERKS.
    
          LS_LGORT-LGORT = GS_VBLKP-LGORT.
          APPEND LS_LGORT TO LT_LGORT.
    
          LV_COUNTER = 0.
    
        ENDIF.
      ENDIF.
      LV_LGORT = GS_VBLKP-LGORT.
      LV_WERKS = GS_VBLKP-WERKS.
     ENDLOOP.
     MOVE-CORRESPONDING LT_LGORT to GT_LGORT_HDR.
    

    Then in the Scripting for GV_LGORT , I'm taking the Page number and passing it to the GT_LGORT_HDR table to get the LGORT.

    It's working fine. But need your inputs, is this okay?

    Thank you,

    Justin.


    Capture.PNG (3.6 kB)
    Capture.PNG (13.5 kB)
    Add comment
    10|10000 characters needed characters exceeded

    • Hello Justin,

          Yes, Now you got me.  When I told you the script based on screenshot of binding, you did not create GT_LGORT_HDR table in interface. After that you told me that you have created this table and program is working according your requirement.   I suggested you an simple alternative of creating table in interface, and had told you clearly
           

      It's up to you that you want solve it by doing extra efforts in interface or want to solve it by using simple script on form layout.

      Regards

      Piyush

  • Sep 28, 2015 at 04:05 AM

    Any one have an answer for the question. Please let me know if it wasn't clear.

    Add comment
    10|10000 characters needed characters exceeded

    • Hello Justin,

      1.  Please provide screenshot for binding of LGORT field.

      2.  what is the type GV_LGORT field?  Have you declared it in interface or simply took a text field on

           master page and named it as GV_LGORT?

      3. You had told that you applied conditional break then what is the need of below script

      4. Run the program without above code, but use my provided code. And see if you conditional break is working or not without above formCalc script.

        

      Let me know the above four points

      Regards

      Piyush

  • Oct 04, 2015 at 05:32 PM

    Hello Piyush,

    I'm sorry I think there was a confusion. The script I have given that was not for conditional breaks, if you see I have said it is for GV_LGORT  - event Calculate. The script is taking the values from LGORT and  putting it into GV_LGORT.  I have disabled that calculate scripting and executed your script all these time. I just pointed that script to you, to tell that's what SAP had it by default for GV_LGORT.

    Now to answer your questions.

    1)Please see the below screenshot

    2) GV_LGORT field is defined at the Interface, but it's not binded.

    3) This is responsible for Conditional Break, not the script which I have given earlier.

    ( DATA[-1].WERKS ne DATA.WERKS ) or ( DATA[-1].LGORT ne DATA.LGORT ) or ( DATA[-1].LGNUM ne DATA.LGNUM )

    Thank you,

    Justin.


    Untitled.png (17.5 kB)
    Capture.PNG (11.9 kB)
    Untitled1.png (16.4 kB)
    Untitled2.png (30.4 kB)
    Add comment
    10|10000 characters needed characters exceeded

  • Oct 08, 2015 at 04:14 AM

    Had to redesign the layout.. Somehow I can't able to get it work with the standard delivered content.

    Add comment
    10|10000 characters needed characters exceeded